~/algor $ cat problems/stack-asteroidlar
Asteroid collisions
$n$ asteroids fly along a line at the same speed; from left to right they are in the order $a_{1}, a_{2}, \dots, a_{n}$. $|a_{i}|$ is the size of the asteroid and the sign is its direction: positive means it flies to the right, negative to the left. When two asteroids collide, the smaller one disappears; if their sizes are equal, both do. Asteroids flying in the same direction never collide. Print the asteroids left after all collisions from left to right; if none are left, print -.
Input
The first line contains a positive integer $n$.
The second line contains $n$ non-zero integers $a_{i}$.
Output
The remaining asteroids (separated by spaces) or -.
Note
$1 \le n \le 2 \cdot 10^{5}$
$1 \le |a_{i}| \le 10^{9}$
Examples
5 5 10 -5 -12 3
-12 3
2 8 -8
-