def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best
n = int(input())
arr = list(map(int, input().split()))
print(rally(arr)) def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best rally p = max(arr) p max(arr) max arr summ = 0 summ 0 best = float('inf') best float('inf') float 'inf' for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	 i range(1, p+1) range 1 p+1 p 1 summ = 0 summ 0 for j in arr:
			summ += (j - i) ** 2
		 j arr summ += (j - i) ** 2 summ (j - i) ** 2 j - i j i 2 best = min(best, summ) best min(best, summ) min best summ return best best arr arr n = int(input()) n int(input()) int input() input arr = list(map(int, input().split())) arr list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split print(rally(arr)) print rally(arr) rally arr def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best rally n = int(input()) int(input()) n arr = list(map(int, input().split())) list(map(int, input().split())) arr
def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best
n = int(input())
arr = list(map(int, input().split()))
print(rally(arr))