#!/usr/local/bin/python3

import math

def power(P, X):
    ans = 0
    for x in X:
        ans += (x-P)**2
    return ans

N = int(input())
X = list(map(int, input().split()))
ave = sum(X)/N
candP = (math.ceil(ave), math.floor(ave))
power = min(map(lambda P: power(P, X), candP))

print(power) import math math def power(P, X):
    ans = 0
    for x in X:
        ans += (x-P)**2
    return ans power 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 return ans ans P P X X 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 ave = sum(X)/N ave sum(X)/N sum(X) sum X N candP = (math.ceil(ave), math.floor(ave)) candP (math.ceil(ave), math.floor(ave)) math.ceil(ave) math.ceil math ceil ave math.floor(ave) math.floor math floor ave power = min(map(lambda P: power(P, X), candP)) power min(map(lambda P: power(P, X), candP)) min map(lambda P: power(P, X), candP) map lambda P: power(P, X) power(P, X) power P X P candP print(power) print power N = int(input()) int(input()) N X = list(map(int, input().split())) list(map(int, input().split())) X ave = sum(X)/N sum(X)/N ave candP = (math.ceil(ave), math.floor(ave)) (math.ceil(ave), math.floor(ave)) candP power = min(map(lambda P: power(P, X), candP)) min(map(lambda P: power(P, X), candP)) power def power(P, X):
    ans = 0
    for x in X:
        ans += (x-P)**2
    return ans def power(P, X):
    ans = 0
    for x in X:
        ans += (x-P)**2
    return ans power
#!/usr/local/bin/python3

import math

def power(P, X):
    ans = 0
    for x in X:
        ans += (x-P)**2
    return ans

N = int(input())
X = list(map(int, input().split()))
ave = sum(X)/N
candP = (math.ceil(ave), math.floor(ave))
power = min(map(lambda P: power(P, X), candP))

print(power)
