import statistics

n=int(input())
x=list(map(int,input().split()))
p1 = int(statistics.mean(x))
p2=p1+1
s1=0
s2=0
for i in range(n):
    s1+=(x[i]-p1)**2
    s2+=(x[i]-p2)**2
print(min(s1,s2)) import statistics statistics 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 p1 = int(statistics.mean(x)) p1 int(statistics.mean(x)) int statistics.mean(x) statistics.mean statistics mean x p2=p1+1 p2 p1+1 p1 1 s1=0 s1 0 s2=0 s2 0 for i in range(n):
    s1+=(x[i]-p1)**2
    s2+=(x[i]-p2)**2 i range(n) range n s1+=(x[i]-p1)**2 s1 (x[i]-p1)**2 x[i]-p1 x[i] x i p1 2 s2+=(x[i]-p2)**2 s2 (x[i]-p2)**2 x[i]-p2 x[i] x i p2 2 print(min(s1,s2)) print min(s1,s2) min s1 s2 n=int(input()) int(input()) n x=list(map(int,input().split())) list(map(int,input().split())) x s2+=(x[i]-p2)**2 (x[i]-p2)**2 s2 p1 = int(statistics.mean(x)) int(statistics.mean(x)) p1 s2=0 0 s2 p2=p1+1 p1+1 p2 s1+=(x[i]-p1)**2 (x[i]-p1)**2 s1 s1=0 0 s1
import statistics

n=int(input())
x=list(map(int,input().split()))
p1 = int(statistics.mean(x))
p2=p1+1
s1=0
s2=0
for i in range(n):
    s1+=(x[i]-p1)**2
    s2+=(x[i]-p2)**2
print(min(s1,s2))
