Pasha is also against "tails"?
Pasha will perfectly manage to study exactly one topic in mathematics before the exam, but there are many tasks on the exam and from different topics, so what to do?
Pasha has learned to change the topics of exam tasks. So he won't fail.
If the topic of the task is , then in one operation Pasha can change the topic of the task in one of the following ways:
;
.
In other words, in one operation Pasha can choose some element of the array and change it by one.
Pasha was lucky to find exam tickets in the e-learning system, there are a total of questions, each of which is characterized by a single number . However, things are not so smooth, so to minimize the chance of getting caught, he must make the minimum possible number of operations.
Your task is to transform all tasks into tasks of one topic with the minimum number of operations.
Input
The first line contains a single integer () — the number of tasks.
The second line contains integers () — the topics of the tasks.
Output
Output a single number — the minimum number of operations.
Examples
Note
In the first test, the optimal solution will be to perform the following operations:
apply the operation to the 2nd task: assign after this the array will become equal to ;
apply the operation to the 3rd task: assign after this the array will become equal to ;
apply the operation to the 3rd task: assign after this the array will become equal to ;
apply the operation to the 3rd task: assign after this the array will become equal to ;
apply the operation to the 4th task: assign after this the array will become equal to ;
It can be shown that obtaining an answer less than is not possible.
Scoring
In this problem, there are conditional blocks. If your solution works correctly for certain constraints, it will receive a certain number of points. Note that each test is graded individually.
( points): , ;
( points): ;
( points): without additional constraints.