Created
July 21, 2017 09:04
-
-
Save IKKO-Ohta/da99bb00ba79f409a05218ccdef541dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input()) | |
A = [int(x) for x in input().split()] | |
MIN,MAX = min(A),max(A) | |
cost = 0 | |
for i in range(MIN,MAX+1): | |
c = 0 | |
for a in A: | |
c += (i - a)*(i - a) | |
cost = min(cost,c) | |
print(cost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment