Negative and positive - MarisaOJ: Marisa Online Judge

Negative and positive

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ with $n$ integer elements, move the negative elements to the beginning of the array and the positive elements to the end of the array. The relative order of elements with the same sign should be maintained. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the array $A$ after rearranging to satisfy the conditions. ### Constraints - $1 \le n \le 1000$. - $-1000 \le A_i \le 1000$. - $A_i \neq 0$. ### Sample Input: ``` 5 1 -2 -5 6 -4 ``` Output: ``` -2 -5 -4 1 6 ```