##############################################
N = int(input())
X = list(map(int, input().split()))

ans = float('inf')

for i in range(min(X), max(X)+1):
    cost = 0
    for x in X:
        cost += (x - i) ** 2

    ans = min(ans, cost)

print(ans) 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 ans = float('inf') ans float('inf') float 'inf' for i in range(min(X), max(X)+1):
    cost = 0
    for x in X:
        cost += (x - i) ** 2

    ans = min(ans, cost) i range(min(X), max(X)+1) range min(X) min X max(X)+1 max(X) max X 1 cost = 0 cost 0 for x in X:
        cost += (x - i) ** 2

     x X cost += (x - i) ** 2 cost (x - i) ** 2 x - i x i 2 ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans X = list(map(int, input().split())) list(map(int, input().split())) X N = int(input()) int(input()) N cost += (x - i) ** 2 (x - i) ** 2 cost ans = float('inf') float('inf') ans cost = 0 0 cost ans = min(ans, cost) min(ans, cost) ans
##############################################
N = int(input())
X = list(map(int, input().split()))

ans = float('inf')

for i in range(min(X), max(X)+1):
    cost = 0
    for x in X:
        cost += (x - i) ** 2

    ans = min(ans, cost)

print(ans)