def c_rally():

    import numpy as np

    import math

    N = int(eval(input()))

    X = [int(i) for i in input().split()]

    m = np.average(X)

    ans = float('inf')

    for j in (math.floor(m), math.ceil(m)):

        ans = min(ans, sum([(x - j)**2 for x in X]))

    return ans



print((c_rally()))
def c_rally():

    N = int(eval(input()))

    X = [int(i) for i in input().split()]



    x_sum = sum(X)

    option = (x_sum // N, (x_sum + N - 1) // N)

    return min(sum([(x - p)**2 for x in X]) for p in option)



print((c_rally()))
def c_rally():
    import numpy as np
    import math

    N = int(eval(input()))
    X = [int(i) for i in input().split()]
    m = np.average(X)
    ans = float("inf")
    for j in (math.floor(m), math.ceil(m)):
        ans = min(ans, sum([(x - j) ** 2 for x in X]))
    return ans


print((c_rally()))

def c_rally():
    N = int(eval(input()))
    X = [int(i) for i in input().split()]
    x_sum = sum(X)
    option = (x_sum // N, (x_sum + N - 1) // N)
    return min(sum([(x - p) ** 2 for x in X]) for p in option)


print((c_rally()))

-    import numpy as np -    import math - -    m = np.average(X) -    ans = float("inf") -    for j in (math.floor(m), math.ceil(m)): -        ans = min(ans, sum([(x - j) ** 2 for x in X])) -    return ans +    x_sum = sum(X) +    option = (x_sum // N, (x_sum + N - 1) // N) +    return min(sum([(x - p) ** 2 for x in X]) for p in option)