Please help

Problem

Code
What is wrong here?

Take the sample input as:

7
5
7
5
5
-6
5
5

check your output against this input, i think it going wrong there.

I get the wrong answer

correct that and u’ll get correct answer.

change n to n+1?

Don’t work.