a=int(input())
b=list(map(int,input().split()))
c=int(sum(b)/len(b)+0.5)
total=0
for i in range(a):
    total+=(b[i]-c)**2
print(total) a=int(input()) a int(input()) int input() input b=list(map(int,input().split())) b list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c=int(sum(b)/len(b)+0.5) c int(sum(b)/len(b)+0.5) int sum(b)/len(b)+0.5 sum(b)/len(b) sum(b) sum b len(b) len b 0.5 total=0 total 0 for i in range(a):
    total+=(b[i]-c)**2 i range(a) range a total+=(b[i]-c)**2 total (b[i]-c)**2 b[i]-c b[i] b i c 2 print(total) print total c=int(sum(b)/len(b)+0.5) int(sum(b)/len(b)+0.5) c total=0 0 total b=list(map(int,input().split())) list(map(int,input().split())) b total+=(b[i]-c)**2 (b[i]-c)**2 total a=int(input()) int(input()) a
a=int(input())
b=list(map(int,input().split()))
c=int(sum(b)/len(b)+0.5)
total=0
for i in range(a):
    total+=(b[i]-c)**2
print(total)