CF1213A.Chips Moving

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Chips Moving

You are given nn chips on a number line. The ii-th chip is placed at the integer coordinate xix_i. Some chips can have equal coordinates.

You can perform each of the two following types of moves any (possibly, zero) number of times on any chip:

  • Move the chip ii by 22 to the left or 22 to the right for free (i.e. replace the current coordinate xix_i with xi2x_i - 2 or with xi+2x_i + 2);
  • move the chip ii by 11 to the left or 11 to the right and pay one coin for this move (i.e. replace the current coordinate xix_i with xi1x_i - 1 or with xi+1x_i + 1).

Note that it's allowed to move chips to any integer coordinate, including negative and zero.

Your task is to find the minimum total number of coins required to move all nn chips to the same coordinate (i.e. all xix_i should be equal after some sequence of moves).

Input

The first line of the input contains one integer nn (1n1001 \le n \le 100) — the number of chips.

The second line of the input contains nn integers x1,x2,,xnx_1, x_2, \dots, x_n (1xi1091 \le x_i \le 10^9), where xix_i is the coordinate of the ii-th chip.

Output

Print one integer — the minimum total number of coins required to move all nn chips to the same coordinate.

Note

In the first example you need to move the first chip by 22 to the right and the second chip by 11 to the right or move the third chip by 22 to the left and the second chip by 11 to the left so the answer is 11.

In the second example you need to move two chips with coordinate 33 by 11 to the left so the answer is 22.

Samples

3
1 2 3
1
5
2 2 2 3 3
2

在线编程 IDE

建议全屏模式获得最佳体验