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

mid = sum(x)//len(x)

ans = float('inf')
for i in [-1, 0, 1]:
    temp = sum([(i+j-mid)**2 for j in x])
    ans = min(temp, ans)
print(ans) 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 mid = sum(x)//len(x) mid sum(x)//len(x) sum(x) sum x len(x) len x ans = float('inf') ans float('inf') float 'inf' for i in [-1, 0, 1]:
    temp = sum([(i+j-mid)**2 for j in x])
    ans = min(temp, ans) i [-1, 0, 1] -1 0 1 (i+j-mid)**2 for j in x for j in x j x for j in x (i+j-mid)**2 i+j-mid i+j i j mid 2 temp = sum([(i+j-mid)**2 for j in x]) temp sum([(i+j-mid)**2 for j in x]) sum [(i+j-mid)**2 for j in x] ans = min(temp, ans) ans min(temp, ans) min temp ans print(ans) print ans n = int(input()) int(input()) n x = list(map(int, input().split())) list(map(int, input().split())) x mid = sum(x)//len(x) sum(x)//len(x) mid ans = min(temp, ans) min(temp, ans) ans ans = float('inf') float('inf') ans temp = sum([(i+j-mid)**2 for j in x]) sum([(i+j-mid)**2 for j in x]) temp
n = int(input())
x = list(map(int, input().split()))

mid = sum(x)//len(x)

ans = float('inf')
for i in [-1, 0, 1]:
    temp = sum([(i+j-mid)**2 for j in x])
    ans = min(temp, ans)
print(ans)
