Question
Sphere Collisions
In a mystical land, a young inventor named Rohan has acquired a special array balls of energy spheres, each with unique properties. These spheres are represented by integers, where the absolute value indicates the size of the sphere, and the sign indicates its direction: positive values move right, and negative values move left.
All the spheres move at the same speed, and Rohan is curious to see what happens when they collide.
If two spheres meet, the smaller one will disintegrate. If they are the same size, both will explode. However, spheres moving in the same direction will never collide.
Rohan needs your help to determine the final state of the spheres after all possible collisions. Can you predict which spheres will remain after the chaos?
All the spheres move at the same speed, and Rohan is curious to see what happens when they collide.
If two spheres meet, the smaller one will disintegrate. If they are the same size, both will explode. However, spheres moving in the same direction will never collide.
Rohan needs your help to determine the final state of the spheres after all possible collisions. Can you predict which spheres will remain after the chaos?
Input
The first line of the input contains an integer n denoting the length of the array balls
The following line contains n space-separated integers denoting the properties of the energy spheres.
Constraints
2 ≤ n ≤ 104
-1000 ≤ balls[i] ≤ 1000
Note: balls[i] != 0
The following line contains n space-separated integers denoting the properties of the energy spheres.
Constraints
2 ≤ n ≤ 104
-1000 ≤ balls[i] ≤ 1000
Note: balls[i] != 0
Output
Print an array denoting the remaining energy spheres after the collision.
Example
Sample Input
3
5 10 -5
Sample Output
5 10
Explanation
Sphere 10 and -5 will collide and sphere 10 will survive. Also, 5 and 10 will never collide as they are moving in same direction. Thus, spheres 5 and 10 will remain at last.
3
5 10 -5
Sample Output
5 10
Explanation
Sphere 10 and -5 will collide and sphere 10 will survive. Also, 5 and 10 will never collide as they are moving in same direction. Thus, spheres 5 and 10 will remain at last.