Undo what is done to l. l has w added and the sum multiplied by 2, so divide by 2 and subtract w:
... l = P/2 -w
9.5m questions
12.2m answers