#C12484. Sort Even Numbers in a List

    ID: 41916 Type: Default 1000ms 256MiB

Sort Even Numbers in a List

Sort Even Numbers in a List

You are given a list of integers. Your task is to sort all the even numbers in the list in ascending order while keeping the odd numbers in their original positions. In other words, if we define an even number as an integer satisfying \( x \bmod 2 = 0 \), then all such numbers must be rearranged in increasing order, and the others should remain untouched.

Example: Consider the list [5, 3, 2, 8, 1, 4]. The even numbers [2, 8, 4] when sorted become [2, 4, 8]. Replacing them in their original positions yields [5, 3, 2, 4, 1, 8].

inputFormat

The input is read from stdin in the following format:

  • The first line contains an integer \( n \) (\(1 \le n \le 10^5\)) representing the number of elements in the list.
  • The second line contains \( n \) space-separated integers.

outputFormat

Print the modified list as space-separated integers on a single line to stdout after sorting the even numbers, while the odd numbers remain in their original positions.

## sample
4
1 3 5 7
1 3 5 7