import math
n = int(input())
x = list(map(int,input().split(" ")))
a=math.ceil(sum(x)/n)
s = sum((xx - a)**2 for xx in x)
tmp = s
a = a-1
s = sum((xx - a)**2 for xx in x)
if s > tmp:
    print(tmp)
else:
    print(s) import math math n = int(input()) n int(input()) int input() input x = list(map(int,input().split(" "))) x list(map(int,input().split(" "))) list map(int,input().split(" ")) map int input().split(" ") ().split () input split " " a=math.ceil(sum(x)/n) a math.ceil(sum(x)/n) math.ceil math ceil sum(x)/n sum(x) sum x n s = sum((xx - a)**2 for xx in x) s sum((xx - a)**2 for xx in x) sum (xx - a)**2 xx - a xx a 2 tmp = s tmp s a = a-1 a a-1 a 1 s = sum((xx - a)**2 for xx in x) s sum((xx - a)**2 for xx in x) sum (xx - a)**2 xx - a xx a 2 if s > tmp:
    print(tmp)
else:
    print(s) s > tmp s tmp print(tmp) print tmp print(s) print s a = a-1 a-1 a s = sum((xx - a)**2 for xx in x) sum((xx - a)**2 for xx in x) s s = sum((xx - a)**2 for xx in x) sum((xx - a)**2 for xx in x) s n = int(input()) int(input()) n tmp = s s tmp x = list(map(int,input().split(" "))) list(map(int,input().split(" "))) x a=math.ceil(sum(x)/n) math.ceil(sum(x)/n) a
import math
n = int(input())
x = list(map(int,input().split(" ")))
a=math.ceil(sum(x)/n)
s = sum((xx - a)**2 for xx in x)
tmp = s
a = a-1
s = sum((xx - a)**2 for xx in x)
if s > tmp:
    print(tmp)
else:
    print(s)