The test case has some problem, for this case there should be three month output, I don't know why the fourth month get outputted in the expected output. And some people earlier wondering why it is 130 instead of 150, I think if we exclude the fourth month, then the result is 130.
Plus, I think the question has changed. According to previous post, it seems that the solution is to sum all the salary cumulatively except for the last month. But as of now the question is "over a period of 3 months", so we only need to sum up three month instead of all previous month exclude the last month.