import math
a = int(input())
answer = 100000000
b = list(map(int,input().split()))
for i in range(1,101):
    cost = 0
    for j in b:
        cost+=(j-i)**2
    answer = min(answer,cost)
print(answer) import math math a = int(input()) a int(input()) int input() input answer = 100000000 answer 100000000 b = list(map(int,input().split())) b list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in range(1,101):
    cost = 0
    for j in b:
        cost+=(j-i)**2
    answer = min(answer,cost) i range(1,101) range 1 101 cost = 0 cost 0 for j in b:
        cost+=(j-i)**2
     j b cost+=(j-i)**2 cost (j-i)**2 j-i j i 2 answer = min(answer,cost) answer min(answer,cost) min answer cost print(answer) print answer cost+=(j-i)**2 (j-i)**2 cost b = list(map(int,input().split())) list(map(int,input().split())) b cost = 0 0 cost answer = 100000000 100000000 answer a = int(input()) int(input()) a answer = min(answer,cost) min(answer,cost) answer
import math
a = int(input())
answer = 100000000
b = list(map(int,input().split()))
for i in range(1,101):
    cost = 0
    for j in b:
        cost+=(j-i)**2
    answer = min(answer,cost)
print(answer)