N = int(input())
X = list(map(int,input().split()))
avg = sum(X)//N
sums_1 = 0
sums_2 = 0
for i in X:
    sums_1 += (avg - i)**2

for j in X:
    sums_2 += (avg+1 - j)**2


print(min(sums_1,sums_2)) 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 avg = sum(X)//N avg sum(X)//N sum(X) sum X N sums_1 = 0 sums_1 0 sums_2 = 0 sums_2 0 for i in X:
    sums_1 += (avg - i)**2 i X sums_1 += (avg - i)**2 sums_1 (avg - i)**2 avg - i avg i 2 for j in X:
    sums_2 += (avg+1 - j)**2 j X sums_2 += (avg+1 - j)**2 sums_2 (avg+1 - j)**2 avg+1 - j avg+1 avg 1 j 2 print(min(sums_1,sums_2)) print min(sums_1,sums_2) min sums_1 sums_2 sums_2 += (avg+1 - j)**2 (avg+1 - j)**2 sums_2 avg = sum(X)//N sum(X)//N avg sums_1 += (avg - i)**2 (avg - i)**2 sums_1 X = list(map(int,input().split())) list(map(int,input().split())) X sums_1 = 0 0 sums_1 sums_2 = 0 0 sums_2 N = int(input()) int(input()) N
N = int(input())
X = list(map(int,input().split()))
avg = sum(X)//N
sums_1 = 0
sums_2 = 0
for i in X:
    sums_1 += (avg - i)**2

for j in X:
    sums_2 += (avg+1 - j)**2


print(min(sums_1,sums_2))