def resolve():
    N = int(input())
    X = list(map(int, input().split()))
    av = sum(X)/N
    def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
    P = round(av)
    ans = 0
    for x in X:
        ans += (x-P)**2
    print(ans)

if '__main__' == __name__:
    resolve() def resolve():
    N = int(input())
    X = list(map(int, input().split()))
    av = sum(X)/N
    def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
    P = round(av)
    ans = 0
    for x in X:
        ans += (x-P)**2
    print(ans) resolve 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 av = sum(X)/N av sum(X)/N sum(X) sum X N def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
     _round import math math p = 10 ** d p 10 ** d 10 d return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p (x*p)%1 < 0.5 (x*p)%1 x*p x p 1 0.5 math.floor(x*p)/p math.floor(x*p) math.floor math floor x*p x p p math.ceil(x*p)/p math.ceil(x*p) math.ceil math ceil x*p x p p x x d=0 d 0 P = round(av) P round(av) round av ans = 0 ans 0 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 if '__main__' == __name__:
    resolve() '__main__' == __name__ '__main__' __name__ resolve() resolve def resolve():
    N = int(input())
    X = list(map(int, input().split()))
    av = sum(X)/N
    def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
    P = round(av)
    ans = 0
    for x in X:
        ans += (x-P)**2
    print(ans) def resolve():
    N = int(input())
    X = list(map(int, input().split()))
    av = sum(X)/N
    def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
    P = round(av)
    ans = 0
    for x in X:
        ans += (x-P)**2
    print(ans) resolve
def resolve():
    N = int(input())
    X = list(map(int, input().split()))
    av = sum(X)/N
    def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
    P = round(av)
    ans = 0
    for x in X:
        ans += (x-P)**2
    print(ans)

if '__main__' == __name__:
    resolve()