Easy Balance

Author: QuwsarOhi

Problem Setter: Khondokar Tanbir Ahmed

Intake 35, Department of CSE

Let you have N (0 < N < 101) integers, a1, a2, a3, ..., aN.

Your objective is to have N equal integers by transforming some of them.
You may transform each integer at most once. Transforming an integer x into another integer y costs you (x-y)2 taka.


Find the minimum total cost to achieve your objective.

Input Format

The first line of the input contains an integer number N.

The second line contains N space-separated integers a1, a2, a3, ..., aN (-101 < ai < 101).

Output Format

Print the minimum total cost to achieve the objective.

Samples

Input
2 4 8
Output
8
Input
3 1 1 3
Output
3
Input
3 4 2 5
Output
5
Input
4 -100 -100 -100 -100
Output
0
Limits
Language Time Memory
GNU C 11 1s 512MB
GNU C++ 14 1s 512MB
GNU C++ 11 1s 512MB
PHP 7 1s 1024MB
Java (OpenJDK 8) 1s 4096MB
Statistics
Login To Submit