import sys

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

if len(list(set(x))) == 1:
    print(0)
    sys.exit()

if n == 1:
    print(0)
    sys.exit()

x_min = x[0]
x_max = x[n-1]
min_sum = 10000000
for p in range(x_min, x_max):

    sum = 0
    for e in x:
        len = (e - p)**2
        sum += len
    # print("p", p, "sum", sum, "min_sum", min_sum)
    if sum <= min_sum:
        min_sum = sum
print(min_sum) import sys sys n = int(input()) n int(input()) int input() input x = sorted(list(map(int, input().split()))) x sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split if len(list(set(x))) == 1:
    print(0)
    sys.exit() len(list(set(x))) == 1 len(list(set(x))) len list(set(x)) list set(x) set x 1 print(0) print 0 sys.exit() sys.exit sys exit if n == 1:
    print(0)
    sys.exit() n == 1 n 1 print(0) print 0 sys.exit() sys.exit sys exit x_min = x[0] x_min x[0] x 0 x_max = x[n-1] x_max x[n-1] x n-1 n 1 min_sum = 10000000 min_sum 10000000 for p in range(x_min, x_max):

    sum = 0
    for e in x:
        len = (e - p)**2
        sum += len
    # print("p", p, "sum", sum, "min_sum", min_sum)
    if sum <= min_sum:
        min_sum = sum p range(x_min, x_max) range x_min x_max sum = 0 sum 0 for e in x:
        len = (e - p)**2
        sum += len
    # print("p", p, "sum", sum, "min_sum", min_sum)
     e x len = (e - p)**2 len (e - p)**2 e - p e p 2 sum += len sum len if sum <= min_sum:
        min_sum = sum sum <= min_sum sum min_sum min_sum = sum min_sum sum print(min_sum) print min_sum sum += len len sum min_sum = 10000000 10000000 min_sum x_min = x[0] x[0] x_min x = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) x n = int(input()) int(input()) n sum = 0 0 sum len = (e - p)**2 (e - p)**2 len x_max = x[n-1] x[n-1] x_max min_sum = sum sum min_sum
import sys

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

if len(list(set(x))) == 1:
    print(0)
    sys.exit()

if n == 1:
    print(0)
    sys.exit()

x_min = x[0]
x_max = x[n-1]
min_sum = 10000000
for p in range(x_min, x_max):

    sum = 0
    for e in x:
        len = (e - p)**2
        sum += len
    # print("p", p, "sum", sum, "min_sum", min_sum)
    if sum <= min_sum:
        min_sum = sum
print(min_sum)
