Help Cupid

No attempts yetTime limit3sMemory limit256 MB

Problem

Cupid's workload keeps growing, so he is bringing in new technology. He put the best programmers on his staff on a project called Advanced Couples Matching (ACM). The project needs an algorithm that takes an even number NN of single people and splits them into N/2N/2 couples, so that every person belongs to exactly one couple.

The data available about each person is thin. Gender, ethnicity, age and nationality are not sensible criteria for forming couples, so the programmers may use only data about each candidate's internet connection. For this stage they settled on time zones. People who live in nearby time zones find it easier to be online at the same moment, so the programmers decided to build the couples so that the total time difference is as small as possible.

A time zone is an integer from 11-11 to 1212 that gives its offset in hours from Coordinated Universal Time (UTC). For two people living in time zones ii and jj, the time difference is the smaller of ij|i - j| and 24ij24 - |i - j|. Given a partition of the NN candidates into N/2N/2 couples, its total time difference is the sum of the time difference of every couple.

Write a program that reads the time zones of NN candidates and prints the minimum total time difference over all partitions of the candidates into couples.

Input

The first line contains an even integer NN (2N10002 \le N \le 1000), the number of candidates to be coupled. The second line contains NN integers T1,T2,,TNT_1, T_2, \dots, T_N (11Ti12-11 \le T_i \le 12), the time zones of the candidates.

Output

Print one line with an integer, the minimum total time difference over all partitions of the candidates into couples.