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

def average(a):
  return sum(a) / len(a)

avg = average(X)

res = 0
if avg - int(avg) >= 0.5:
  for i in X:
    res += (i - math.ceil(avg)) **2
else:
  for i in X:
    res += (i - math.floor(avg)) ** 2
print(res) import math math 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 average(a):
  return sum(a) / len(a) average return sum(a) / len(a) sum(a) / len(a) sum(a) sum a len(a) len a a a avg = average(X) avg average(X) average X res = 0 res 0 if avg - int(avg) >= 0.5:
  for i in X:
    res += (i - math.ceil(avg)) **2
else:
  for i in X:
    res += (i - math.floor(avg)) ** 2 avg - int(avg) >= 0.5 avg - int(avg) avg int(avg) int avg 0.5 for i in X:
    res += (i - math.ceil(avg)) **2 i X res += (i - math.ceil(avg)) **2 res (i - math.ceil(avg)) **2 i - math.ceil(avg) i math.ceil(avg) math.ceil math ceil avg 2 for i in X:
    res += (i - math.floor(avg)) ** 2 i X res += (i - math.floor(avg)) ** 2 res (i - math.floor(avg)) ** 2 i - math.floor(avg) i math.floor(avg) math.floor math floor avg 2 print(res) print res def average(a):
  return sum(a) / len(a) def average(a):
  return sum(a) / len(a) average N = int(input()) int(input()) N avg = average(X) average(X) avg res += (i - math.ceil(avg)) **2 (i - math.ceil(avg)) **2 res res = 0 0 res res += (i - math.floor(avg)) ** 2 (i - math.floor(avg)) ** 2 res X = list(map(int, input().split())) list(map(int, input().split())) X
import math
N = int(input())
X = list(map(int, input().split()))

def average(a):
  return sum(a) / len(a)

avg = average(X)

res = 0
if avg - int(avg) >= 0.5:
  for i in X:
    res += (i - math.ceil(avg)) **2
else:
  for i in X:
    res += (i - math.floor(avg)) ** 2
print(res)