{"raw_statement":[{"iden":"problem statement","content":"Evi has $N$ integers $a_1,a_2,..,a_N$. His objective is to have $N$ equal **integers** by transforming some of them.\nHe may transform each integer at most once. Transforming an integer $x$ into another integer $y$ costs him $(x-y)^2$ dollars. Even if $a_i=a_j (i≠j)$, he has to pay the cost separately for transforming each of them (See Sample 2).\nFind the minimum total cost to achieve his objective."},{"iden":"constraints","content":"*   $1≦N≦100$\n*   $-100≦a_i≦100$"},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$a_1$ $a_2$ ... $a_N$"},{"iden":"sample input 1","content":"2\n4 8"},{"iden":"sample output 1","content":"8\n\nTransforming the both into $6$s will cost $(4-6)^2+(8-6)^2=8$ dollars, which is the minimum."},{"iden":"sample input 2","content":"3\n1 1 3"},{"iden":"sample output 2","content":"3\n\nTransforming the all into $2$s will cost $(1-2)^2+(1-2)^2+(3-2)^2=3$ dollars. Note that Evi has to pay $(1-2)^2$ dollar separately for transforming each of the two $1$s."},{"iden":"sample input 3","content":"3\n4 2 5"},{"iden":"sample output 3","content":"5\n\nLeaving the $4$ as it is and transforming the $2$ and the $5$ into $4$s will achieve the total cost of $(2-4)^2+(5-4)^2=5$ dollars, which is the minimum."},{"iden":"sample input 4","content":"4\n-100 -100 -100 -100"},{"iden":"sample output 4","content":"0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is $0$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}