#C13227. Even-Odd List Reordering

    ID: 42742 Type: Default 1000ms 256MiB

Even-Odd List Reordering

Even-Odd List Reordering

You are given a list of integers. Your task is to reorder the list so that all even numbers appear before all odd numbers while preserving their relative order from the original list.

Note: The input will be provided via standard input (stdin) and the output should be printed on standard output (stdout). The first line of input contains an integer n which represents the number of elements in the list. The second line contains n space-separated integers.

Your solution should output a single line with the modified list, where the even numbers (in their original order) come first, followed by the odd numbers (also in their original order). Separate each integer in the output by a single space.

inputFormat

The first line contains an integer n (0 ≤ n ≤ 105), representing the number of elements. The second line contains n space-separated integers.

outputFormat

Output a single line of n space-separated integers after reordering the list such that all even numbers come before the odd numbers, maintaining the relative order of appearance.

## sample
7
3 8 5 2 4 7 6
8 2 4 6 3 5 7

</p>