Sri ram and arrows problem....one test case not passing

The fierce battle of Lord Sri Ram and Ravan is going on. They both are constantly shooting arrows towards each other not necessarily turn by turn. It means that they can shoot multiple arrows at a time.

You are given an array of integers. Here the sign of the integer represents the direction of the arrow, ‘+’ : right and ‘-’ : left. The absolute value represents the size of the arrow. A collisions will take place if an arrow is moving towards right and the next arrow moves in the left direction. At each collision the arrow with larger size destroys the smaller sized arrow and continues the path. If both the arrows have same size then they both are destroyed.

Note: Arrows moving in the same direction (-,- +,+) never collide and neither do the arrows moving away from each other (-,+) collide. The only arrows that collide are the arrows that move towards each other (+,-).

Your task is to help Lord Ram decode the final state of the arrows, So that he can know how many more arrows he needs to shoot.

Input Format
1st line represents the number of elements N in the given array. Next line contains N integers

Constraints
N<=100000
1<= Size of Arrows <=1000

Output Format
Print on a single line space separated, the final state of the arrows

Why have you mentioned this doubt under “quiz on stacks and queues”?

This is a very simple question in which you just have to update the array.
Only in the case of a +ve as previous element and a -ve as current element, those two values will be merged as a single value which is their sum.
rest of the array will be unchanged.