n = int(eval(input()))

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



avg = round(sum(x) / n)



ans = 0



for i in x:

    ans += (i - avg) ** 2



print(ans)
if __name__ == '__main__':

    n = int(eval(input()))

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

    p = round(sum(x) / n)

    ans = 0

    for i in x:

        ans += (i - p) ** 2

    print(ans)

n = int(eval(input()))
x = list(map(int, input().split()))
avg = round(sum(x) / n)
ans = 0
for i in x:
    ans += (i - avg) ** 2
print(ans)

if __name__ == "__main__":
    n = int(eval(input()))
    x = list(map(int, input().split()))
    p = round(sum(x) / n)
    ans = 0
    for i in x:
        ans += (i - p) ** 2
    print(ans)

-n = int(eval(input())) -x = list(map(int, input().split())) -avg = round(sum(x) / n) -ans = 0 -for i in x: -    ans += (i - avg) ** 2 -print(ans) +if __name__ == "__main__": +    n = int(eval(input())) +    x = list(map(int, input().split())) +    p = round(sum(x) / n) +    ans = 0 +    for i in x: +        ans += (i - p) ** 2 +    print(ans)