import sys

import numpy as np



sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

printV = lambda x: print(*x, sep="\n")

printH = lambda x: print(" ".join(map(str,x)))

def IS(): return sys.stdin.readline()[:-1]

def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LI1(): return list(map(int1, sys.stdin.readline().split()))

def LII(rows_number): return [II() for _ in range(rows_number)]

def LLI(rows_number): return [LI() for _ in range(rows_number)]

def LLI1(rows_number): return [LI1() for _ in range(rows_number)]



def main():

	N = II()

	X = LI()

	X = np.array(X)

	m = round(np.sum(X) / N)

	print(int(np.sum((X-m)**2)))



if __name__ == '__main__':

	main()

import sys



sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

printV = lambda x: print(*x, sep="\n")

printH = lambda x: print(" ".join(map(str,x)))

def IS(): return sys.stdin.readline()[:-1]

def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LI1(): return list(map(int1, sys.stdin.readline().split()))

def LII(rows_number): return [II() for _ in range(rows_number)]

def LLI(rows_number): return [LI() for _ in range(rows_number)]

def LLI1(rows_number): return [LI1() for _ in range(rows_number)]



def main():

	N = II()

	X = LI()

	m = round(sum(X) / N)

	ans = 0

	for x in X:

		ans += ((x-m)**2)

	print(ans)



if __name__ == '__main__':

	main()

import sys
import numpy as np

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str, x)))


def IS():
    return sys.stdin.readline()[:-1]


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LI1():
    return list(map(int1, sys.stdin.readline().split()))


def LII(rows_number):
    return [II() for _ in range(rows_number)]


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


def LLI1(rows_number):
    return [LI1() for _ in range(rows_number)]


def main():
    N = II()
    X = LI()
    X = np.array(X)
    m = round(np.sum(X) / N)
    print(int(np.sum((X - m) ** 2)))


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str, x)))


def IS():
    return sys.stdin.readline()[:-1]


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LI1():
    return list(map(int1, sys.stdin.readline().split()))


def LII(rows_number):
    return [II() for _ in range(rows_number)]


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


def LLI1(rows_number):
    return [LI1() for _ in range(rows_number)]


def main():
    N = II()
    X = LI()
    m = round(sum(X) / N)
    ans = 0
    for x in X:
        ans += (x - m) ** 2
    print(ans)


if __name__ == "__main__":
    main()

-import numpy as np -    X = np.array(X) -    m = round(np.sum(X) / N) -    print(int(np.sum((X - m) ** 2))) +    m = round(sum(X) / N) +    ans = 0 +    for x in X: +        ans += (x - m) ** 2 +    print(ans)