import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
X = inintl()

p = 0
min_d = 10**10
ans = 0

for i in range(1,max(X)+1):
    t_d = 0
    for x in X:
        t_d += (x-i)**2
    if t_d < min_d:
        min_d = t_d
        p = i

for x in X:
    ans += (x-p)**2

print(ans) import sys sys inint = lambda: int(sys.stdin.readline()) inint lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline inintm = lambda: map(int, sys.stdin.readline().split()) inintm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inintl = lambda: list(inintm()) inintl lambda: list(inintm()) list(inintm()) list inintm() inintm instr = lambda: sys.stdin.readline() instr lambda: sys.stdin.readline() sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline instrm = lambda: map(str, sys.stdin.readline().split()) instrm lambda: map(str, sys.stdin.readline().split()) map(str, sys.stdin.readline().split()) map str sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split instrl = lambda: list(instrm()) instrl lambda: list(instrm()) list(instrm()) list instrm() instrm n = inint() n inint() inint X = inintl() X inintl() inintl p = 0 p 0 min_d = 10**10 min_d 10**10 10 10 ans = 0 ans 0 for i in range(1,max(X)+1):
    t_d = 0
    for x in X:
        t_d += (x-i)**2
    if t_d < min_d:
        min_d = t_d
        p = i i range(1,max(X)+1) range 1 max(X)+1 max(X) max X 1 t_d = 0 t_d 0 for x in X:
        t_d += (x-i)**2
     x X t_d += (x-i)**2 t_d (x-i)**2 x-i x i 2 if t_d < min_d:
        min_d = t_d
        p = i t_d < min_d t_d min_d min_d = t_d min_d t_d p = i p i for x in X:
    ans += (x-p)**2 x X ans += (x-p)**2 ans (x-p)**2 x-p x p 2 print(ans) print ans inintm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) inintm inintl = lambda: list(inintm()) lambda: list(inintm()) inintl instr = lambda: sys.stdin.readline() lambda: sys.stdin.readline() instr min_d = t_d t_d min_d instrm = lambda: map(str, sys.stdin.readline().split()) lambda: map(str, sys.stdin.readline().split()) instrm ans = 0 0 ans t_d = 0 0 t_d n = inint() inint() n X = inintl() inintl() X p = i i p p = 0 0 p min_d = 10**10 10**10 min_d inint = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) inint ans += (x-p)**2 (x-p)**2 ans instrl = lambda: list(instrm()) lambda: list(instrm()) instrl t_d += (x-i)**2 (x-i)**2 t_d
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
X = inintl()

p = 0
min_d = 10**10
ans = 0

for i in range(1,max(X)+1):
    t_d = 0
    for x in X:
        t_d += (x-i)**2
    if t_d < min_d:
        min_d = t_d
        p = i

for x in X:
    ans += (x-p)**2

print(ans)
