def resolve():
	n = int(input())
	x = list(map(int,input().split()))
	p = round(sum(x)/n)
	ans = 0
	for i in range(n):
		ans += (x[i]-p)**2
	print(ans)
resolve() def resolve():
	n = int(input())
	x = list(map(int,input().split()))
	p = round(sum(x)/n)
	ans = 0
	for i in range(n):
		ans += (x[i]-p)**2
	print(ans) resolve 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 p = round(sum(x)/n) p round(sum(x)/n) round sum(x)/n sum(x) sum x n ans = 0 ans 0 for i in range(n):
		ans += (x[i]-p)**2
	 i range(n) range n ans += (x[i]-p)**2 ans (x[i]-p)**2 x[i]-p x[i] x i p 2 print(ans) print ans resolve() resolve def resolve():
	n = int(input())
	x = list(map(int,input().split()))
	p = round(sum(x)/n)
	ans = 0
	for i in range(n):
		ans += (x[i]-p)**2
	print(ans) def resolve():
	n = int(input())
	x = list(map(int,input().split()))
	p = round(sum(x)/n)
	ans = 0
	for i in range(n):
		ans += (x[i]-p)**2
	print(ans) resolve
def resolve():
	n = int(input())
	x = list(map(int,input().split()))
	p = round(sum(x)/n)
	ans = 0
	for i in range(n):
		ans += (x[i]-p)**2
	print(ans)
resolve()