import numpy as np

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

X = np.sort(X)
minX = X[0]
maxX = X[-1]
ans = 999999999

for i in range(minX, maxX+1, 1):
    x = (X - i) ** 2
    total = np.sum(x)
    ans = min(ans, total)

print(ans) import numpy as np numpy N = int(input()) N int(input()) int input() input X = np.array(list(map(int, input().split()))) X np.array(list(map(int, input().split()))) np.array np array list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split X = np.sort(X) X np.sort(X) np.sort np sort X minX = X[0] minX X[0] X 0 maxX = X[-1] maxX X[-1] X -1 ans = 999999999 ans 999999999 for i in range(minX, maxX+1, 1):
    x = (X - i) ** 2
    total = np.sum(x)
    ans = min(ans, total) i range(minX, maxX+1, 1) range minX maxX+1 maxX 1 1 x = (X - i) ** 2 x (X - i) ** 2 X - i X i 2 total = np.sum(x) total np.sum(x) np.sum np sum x ans = min(ans, total) ans min(ans, total) min ans total print(ans) print ans maxX = X[-1] X[-1] maxX x = (X - i) ** 2 (X - i) ** 2 x ans = min(ans, total) min(ans, total) ans X = np.array(list(map(int, input().split()))) np.array(list(map(int, input().split()))) X minX = X[0] X[0] minX ans = 999999999 999999999 ans X = np.sort(X) np.sort(X) X N = int(input()) int(input()) N total = np.sum(x) np.sum(x) total
import numpy as np

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

X = np.sort(X)
minX = X[0]
maxX = X[-1]
ans = 999999999

for i in range(minX, maxX+1, 1):
    x = (X - i) ** 2
    total = np.sum(x)
    ans = min(ans, total)

print(ans)