Skip to main content
LIVE CONTEST: Round #7 · Begin Marathon is live now! …

~/algor $ cat problems/array/grouping-even-and-odd-numbers

Grouping even and odd numbers

Author Iqbolshoh Ilhomjonov 3 @iqbolshoh 650 problems
Easy 1000 ms 128 MB 27%
Share

A positive integer and an array of integers are given. Print first all array elements with even values, then all elements with odd values, in input order.

Splitting the array elements into even and odd groups

Input

The first line contains a positive integer . The second line contains integers separated by spaces.

Output

One line with integers separated by spaces (even ones first, then odd ones).

Note


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

Sign in to submit a solution

Signing up is free and takes a minute.