import numpy as np

N = int(input())
x_list = list(map(lambda x: int(x), input().split(" ")))
M = np.sum(x_list)
L = np.sum(list(map(lambda x: int(x)**2, x_list)))

if M % N == 0:
    print(int(L - M**2 / N))
else:
    rest = M % N
    if rest <= N / 2:
        print(int(rest**2 / N - M**2 / N + L))
    else:
        print(int(N * (1 - rest / N)**2 - M**2 / N + L)) import numpy as np numpy N = int(input()) N int(input()) int input() input x_list = list(map(lambda x: int(x), input().split(" "))) x_list list(map(lambda x: int(x), input().split(" "))) list map(lambda x: int(x), input().split(" ")) map lambda x: int(x) int(x) int x x input().split(" ") ().split () input split " " M = np.sum(x_list) M np.sum(x_list) np.sum np sum x_list L = np.sum(list(map(lambda x: int(x)**2, x_list))) L np.sum(list(map(lambda x: int(x)**2, x_list))) np.sum np sum list(map(lambda x: int(x)**2, x_list)) list map(lambda x: int(x)**2, x_list) map lambda x: int(x)**2 int(x)**2 int(x) int x 2 x x_list if M % N == 0:
    print(int(L - M**2 / N))
else:
    rest = M % N
    if rest <= N / 2:
        print(int(rest**2 / N - M**2 / N + L))
    else:
        print(int(N * (1 - rest / N)**2 - M**2 / N + L)) M % N == 0 M % N M N 0 print(int(L - M**2 / N)) print int(L - M**2 / N) int L - M**2 / N L M**2 / N M**2 M 2 N rest = M % N rest M % N M N if rest <= N / 2:
        print(int(rest**2 / N - M**2 / N + L))
    else:
        print(int(N * (1 - rest / N)**2 - M**2 / N + L)) rest <= N / 2 rest N / 2 N 2 print(int(rest**2 / N - M**2 / N + L)) print int(rest**2 / N - M**2 / N + L) int rest**2 / N - M**2 / N + L rest**2 / N - M**2 / N rest**2 / N rest**2 rest 2 N M**2 / N M**2 M 2 N L print(int(N * (1 - rest / N)**2 - M**2 / N + L)) print int(N * (1 - rest / N)**2 - M**2 / N + L) int N * (1 - rest / N)**2 - M**2 / N + L N * (1 - rest / N)**2 - M**2 / N N * (1 - rest / N)**2 N (1 - rest / N)**2 1 - rest / N 1 rest / N rest N 2 M**2 / N M**2 M 2 N L L = np.sum(list(map(lambda x: int(x)**2, x_list))) np.sum(list(map(lambda x: int(x)**2, x_list))) L rest = M % N M % N rest N = int(input()) int(input()) N M = np.sum(x_list) np.sum(x_list) M x_list = list(map(lambda x: int(x), input().split(" "))) list(map(lambda x: int(x), input().split(" "))) x_list
import numpy as np

N = int(input())
x_list = list(map(lambda x: int(x), input().split(" ")))
M = np.sum(x_list)
L = np.sum(list(map(lambda x: int(x)**2, x_list)))

if M % N == 0:
    print(int(L - M**2 / N))
else:
    rest = M % N
    if rest <= N / 2:
        print(int(rest**2 / N - M**2 / N + L))
    else:
        print(int(N * (1 - rest / N)**2 - M**2 / N + L))
