N = int(input())
X = list(map(int, input().split()))

def cost(p):
    res = 0
    for x in X:
        res += (x - p)**2
    return res

m = sum(X) // N
print(min(cost(m), cost(m+1))) 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 def cost(p):
    res = 0
    for x in X:
        res += (x - p)**2
    return res cost res = 0 res 0 for x in X:
        res += (x - p)**2
     x X res += (x - p)**2 res (x - p)**2 x - p x p 2 return res res p p m = sum(X) // N m sum(X) // N sum(X) sum X N print(min(cost(m), cost(m+1))) print min(cost(m), cost(m+1)) min cost(m) cost m cost(m+1) cost m+1 m 1 N = int(input()) int(input()) N X = list(map(int, input().split())) list(map(int, input().split())) X m = sum(X) // N sum(X) // N m def cost(p):
    res = 0
    for x in X:
        res += (x - p)**2
    return res def cost(p):
    res = 0
    for x in X:
        res += (x - p)**2
    return res cost
N = int(input())
X = list(map(int, input().split()))

def cost(p):
    res = 0
    for x in X:
        res += (x - p)**2
    return res

m = sum(X) // N
print(min(cost(m), cost(m+1)))