n = int(input())
x = list(map(int,input().split()))

avg1 = sum(x)//n
avg2 = avg1+1

ans1 = int(sum([(i - avg1)**2 for i in x]))
ans2 = int(sum([(i - avg2)**2 for i in x]))

print(min(ans1,ans2)) 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 avg1 = sum(x)//n avg1 sum(x)//n sum(x) sum x n avg2 = avg1+1 avg2 avg1+1 avg1 1 (i - avg1)**2 for i in x for i in x i x for i in x (i - avg1)**2 i - avg1 i avg1 2 ans1 = int(sum([(i - avg1)**2 for i in x])) ans1 int(sum([(i - avg1)**2 for i in x])) int sum([(i - avg1)**2 for i in x]) sum [(i - avg1)**2 for i in x] (i - avg2)**2 for i in x for i in x i x for i in x (i - avg2)**2 i - avg2 i avg2 2 ans2 = int(sum([(i - avg2)**2 for i in x])) ans2 int(sum([(i - avg2)**2 for i in x])) int sum([(i - avg2)**2 for i in x]) sum [(i - avg2)**2 for i in x] print(min(ans1,ans2)) print min(ans1,ans2) min ans1 ans2 n = int(input()) int(input()) n x = list(map(int,input().split())) list(map(int,input().split())) x ans1 = int(sum([(i - avg1)**2 for i in x])) int(sum([(i - avg1)**2 for i in x])) ans1 avg2 = avg1+1 avg1+1 avg2 avg1 = sum(x)//n sum(x)//n avg1 ans2 = int(sum([(i - avg2)**2 for i in x])) int(sum([(i - avg2)**2 for i in x])) ans2
n = int(input())
x = list(map(int,input().split()))

avg1 = sum(x)//n
avg2 = avg1+1

ans1 = int(sum([(i - avg1)**2 for i in x]))
ans2 = int(sum([(i - avg2)**2 for i in x]))

print(min(ans1,ans2))
