N = int(input())
X = [int(x) for x in list(input().split())]
max_x = max(X)
min_x = min(X)
d = max_x - min_x
middle = (d//2)
P = middle + min_x
ans = 0
for i in range(N):
  ans += (max_x-X[i])**2
for i in range(d):
  n_ans = 0
  P = min_x + i
  for j in range(N):
    n_ans += (P-X[j])**2
  if (n_ans < ans):
    ans = n_ans
print(int(ans)) N = int(input()) N int(input()) int input() input int(x) for x in list(input().split()) for x in list(input().split()) x list(input().split()) list input().split() ().split () input split for x in list(input().split()) int(x) int x X = [int(x) for x in list(input().split())] X [int(x) for x in list(input().split())] max_x = max(X) max_x max(X) max X min_x = min(X) min_x min(X) min X d = max_x - min_x d max_x - min_x max_x min_x middle = (d//2) middle d//2 d 2 P = middle + min_x P middle + min_x middle min_x ans = 0 ans 0 for i in range(N):
  ans += (max_x-X[i])**2 i range(N) range N ans += (max_x-X[i])**2 ans (max_x-X[i])**2 max_x-X[i] max_x X[i] X i 2 for i in range(d):
  n_ans = 0
  P = min_x + i
  for j in range(N):
    n_ans += (P-X[j])**2
  if (n_ans < ans):
    ans = n_ans i range(d) range d n_ans = 0 n_ans 0 P = min_x + i P min_x + i min_x i for j in range(N):
    n_ans += (P-X[j])**2
   j range(N) range N n_ans += (P-X[j])**2 n_ans (P-X[j])**2 P-X[j] P X[j] X j 2 if (n_ans < ans):
    ans = n_ans n_ans < ans n_ans ans ans = n_ans ans n_ans print(int(ans)) print int(ans) int ans min_x = min(X) min(X) min_x max_x = max(X) max(X) max_x middle = (d//2) d//2 middle ans = n_ans n_ans ans d = max_x - min_x max_x - min_x d ans += (max_x-X[i])**2 (max_x-X[i])**2 ans N = int(input()) int(input()) N X = [int(x) for x in list(input().split())] [int(x) for x in list(input().split())] X ans = 0 0 ans n_ans += (P-X[j])**2 (P-X[j])**2 n_ans P = min_x + i min_x + i P P = middle + min_x middle + min_x P n_ans = 0 0 n_ans
N = int(input())
X = [int(x) for x in list(input().split())]
max_x = max(X)
min_x = min(X)
d = max_x - min_x
middle = (d//2)
P = middle + min_x
ans = 0
for i in range(N):
  ans += (max_x-X[i])**2
for i in range(d):
  n_ans = 0
  P = min_x + i
  for j in range(N):
    n_ans += (P-X[j])**2
  if (n_ans < ans):
    ans = n_ans
print(int(ans))