#P1213A. Chips Moving
Chips Moving
No submission language available for this problem.
Description
You are given chips on a number line. The -th chip is placed at the integer coordinate . 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 by to the left or to the right for free (i.e. replace the current coordinate with or with );
- move the chip by to the left or to the right and pay one coin for this move (i.e. replace the current coordinate with or with ).
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 chips to the same coordinate (i.e. all should be equal after some sequence of moves).
The first line of the input contains one integer () — the number of chips.
The second line of the input contains integers (), where is the coordinate of the -th chip.
Print one integer — the minimum total number of coins required to move all chips to the same coordinate.
Input
The first line of the input contains one integer () — the number of chips.
The second line of the input contains integers (), where is the coordinate of the -th chip.
Output
Print one integer — the minimum total number of coins required to move all chips to the same coordinate.
Samples
Note
In the first example you need to move the first chip by to the right and the second chip by to the right or move the third chip by to the left and the second chip by to the left so the answer is .
In the second example you need to move two chips with coordinate by to the left so the answer is .