#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
x = list(map(int, input().split()))

mix_x = min(x)
max_x = max(x)

ans = 10000000000000
for i in range(mix_x, max_x+1):
    power = 0
    for j in range(n):
        power += (x[j] - i)**2
    ans = min(ans, power)
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 mix_x = min(x) mix_x min(x) min x max_x = max(x) max_x max(x) max x ans = 10000000000000 ans 10000000000000 for i in range(mix_x, max_x+1):
    power = 0
    for j in range(n):
        power += (x[j] - i)**2
    ans = min(ans, power) i range(mix_x, max_x+1) range mix_x max_x+1 max_x 1 power = 0 power 0 for j in range(n):
        power += (x[j] - i)**2
     j range(n) range n power += (x[j] - i)**2 power (x[j] - i)**2 x[j] - i x[j] x j i 2 ans = min(ans, power) ans min(ans, power) min ans power print(ans) print ans ans = 10000000000000 10000000000000 ans power = 0 0 power power += (x[j] - i)**2 (x[j] - i)**2 power n = int(input()) int(input()) n max_x = max(x) max(x) max_x ans = min(ans, power) min(ans, power) ans mix_x = min(x) min(x) mix_x x = list(map(int, input().split())) list(map(int, input().split())) x
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
x = list(map(int, input().split()))

mix_x = min(x)
max_x = max(x)

ans = 10000000000000
for i in range(mix_x, max_x+1):
    power = 0
    for j in range(n):
        power += (x[j] - i)**2
    ans = min(ans, power)
print(ans)



