n=int(input())
l=list(map(int,input().split()))
s=sum(l)//n
k=1+(sum(l)//n)
c=0
x=0
for i in range(n):
    c+=(l[i]-s)**2
for i in range(n):
    x+=(l[i]-k)**2
print(min(c,x)) n=int(input()) n int(input()) int input() input l=list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s=sum(l)//n s sum(l)//n sum(l) sum l n k=1+(sum(l)//n) k 1+(sum(l)//n) 1 sum(l)//n sum(l) sum l n c=0 c 0 x=0 x 0 for i in range(n):
    c+=(l[i]-s)**2 i range(n) range n c+=(l[i]-s)**2 c (l[i]-s)**2 l[i]-s l[i] l i s 2 for i in range(n):
    x+=(l[i]-k)**2 i range(n) range n x+=(l[i]-k)**2 x (l[i]-k)**2 l[i]-k l[i] l i k 2 print(min(c,x)) print min(c,x) min c x l=list(map(int,input().split())) list(map(int,input().split())) l c=0 0 c x=0 0 x k=1+(sum(l)//n) 1+(sum(l)//n) k c+=(l[i]-s)**2 (l[i]-s)**2 c s=sum(l)//n sum(l)//n s n=int(input()) int(input()) n x+=(l[i]-k)**2 (l[i]-k)**2 x
n=int(input())
l=list(map(int,input().split()))
s=sum(l)//n
k=1+(sum(l)//n)
c=0
x=0
for i in range(n):
    c+=(l[i]-s)**2
for i in range(n):
    x+=(l[i]-k)**2
print(min(c,x))
