def main():

    n = eval(input())

    array = list(map(int, input().split(" ")))

    minX = min(array)

    maxX = max(array)

    p_sum = 0

    power_list = []

    for p in range(minX, maxX + 1):

        for x in array:

            p_sum += power(x, p)

        power_list.append(p_sum)

        p_sum = 0        

    print((min(power_list)))



def power(x, p):

    return (x - p)**2



if __name__ == "__main__":

    main()

def main():

    n = int(eval(input()))

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

    min_x = round(sum(x) / n)

    ans = sum([(min_x - i)**2 for i in x])

    print(ans)



if __name__ == "__main__":

    main()

def main():
    n = eval(input())
    array = list(map(int, input().split(" ")))
    minX = min(array)
    maxX = max(array)
    p_sum = 0
    power_list = []
    for p in range(minX, maxX + 1):
        for x in array:
            p_sum += power(x, p)
        power_list.append(p_sum)
        p_sum = 0
    print((min(power_list)))


def power(x, p):
    return (x - p) ** 2


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    x = [int(i) for i in input().split()]
    min_x = round(sum(x) / n)
    ans = sum([(min_x - i) ** 2 for i in x])
    print(ans)


if __name__ == "__main__":
    main()

-    n = eval(input()) -    array = list(map(int, input().split(" "))) -    minX = min(array) -    maxX = max(array) -    p_sum = 0 -    power_list = [] -    for p in range(minX, maxX + 1): -        for x in array: -            p_sum += power(x, p) -        power_list.append(p_sum) -        p_sum = 0 -    print((min(power_list))) - - -def power(x, p): -    return (x - p) ** 2 +    n = int(eval(input())) +    x = [int(i) for i in input().split()] +    min_x = round(sum(x) / n) +    ans = sum([(min_x - i) ** 2 for i in x]) +    print(ans)