~/algor $ cat problems/massiv-juft-va-toq-ajratish
Grouping even and odd numbers
Easy
1000 ms
128 MB
27%
A positive integer $n$ and an array of $n$ integers are given. Print first all array elements with even values, then all elements with odd values, in input order.
Input
The first line contains a positive integer $n$. The second line contains $n$ integers separated by spaces.
Output
One line with $n$ integers separated by spaces (even ones first, then odd ones).
Note
$1 \le n \le 1000$
$-10^{9} \le a_{i} \le 10^{9}$
Examples
Input #1
6 4 7 2 9 8 5
Output #1
4 2 8 7 9 5
Input #2
4 1 3 2 4
Output #2
2 4 1 3