Not accounting for all testcases

not producing correct o/p for this case
7 6 5 4 3 2 -1
5