cswork / OAOpen practice workspace

SnowflakeOA #40

Custom-Sorted Array

Estimated EasyJudge-ready

Topics (AI-labelled)Two Pointers

One operation swaps the elements at any two indices. All even numbers must come before all odd numbers. Neither group needs to be sorted internally, and swaps are not limited to adjacent elements.

Input

The first line contains n, and the second line contains positive integers. This site uses 1≤n≤200000 and 1≤element≤10⁹.

Output

Output the single integer required by the problem.

Example 1

Input:

4
6 3 4 5

Output:

1

Example 2

Input:

4
1 1 2 2

Output:

2

Example 3

Input:

3
2 4 6

Output:

0

Example notes

The answers to the three public examples are, in order: 1; 2; 0. The examples were rechecked by independent enumeration, state search, or direct simulation.

Editorial

Loading solution…