import sys

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

# i = min(x)
# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    # i += 1
print(ans) import sys sys n = input() n 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 ans = sys.maxsize ans sys.maxsize sys maxsize for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    # i += 1 i range(min(x),max(x)+1,1) range min(x) min x max(x)+1 max(x) max x 1 1 tmp = sum(map(lambda p: (p-i)**2,x)) tmp sum(map(lambda p: (p-i)**2,x)) sum map(lambda p: (p-i)**2,x) map lambda p: (p-i)**2 (p-i)**2 p-i p i 2 p x if ans > tmp:
        ans = tmp
    # i += 1 ans > tmp ans tmp ans = tmp ans tmp print(ans) print ans x = list(map(int,input().split())) list(map(int,input().split())) x ans = sys.maxsize sys.maxsize ans tmp = sum(map(lambda p: (p-i)**2,x)) sum(map(lambda p: (p-i)**2,x)) tmp n = input() input() n ans = tmp tmp ans
import sys

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

# i = min(x)
# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    # i += 1
print(ans)