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

min =10**5
meandown = math.floor(sum(Xlist)/N)
meanup = math.ceil(sum(Xlist)/N)
sumdown=0
sumup = 0
for i in range(len(Xlist)):
  sumdown+= (Xlist[i]-meandown)**2
  sumup+= (Xlist[i]-meanup)**2
  
if sumdown<sumup:
  print(sumdown)
else:
  print (sumup) import math math N = int(input()) N int(input()) int input() input Xlist = list(map(int,input().split())) Xlist list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split min =10**5 min 10**5 10 5 meandown = math.floor(sum(Xlist)/N) meandown math.floor(sum(Xlist)/N) math.floor math floor sum(Xlist)/N sum(Xlist) sum Xlist N meanup = math.ceil(sum(Xlist)/N) meanup math.ceil(sum(Xlist)/N) math.ceil math ceil sum(Xlist)/N sum(Xlist) sum Xlist N sumdown=0 sumdown 0 sumup = 0 sumup 0 for i in range(len(Xlist)):
  sumdown+= (Xlist[i]-meandown)**2
  sumup+= (Xlist[i]-meanup)**2
   i range(len(Xlist)) range len(Xlist) len Xlist sumdown+= (Xlist[i]-meandown)**2 sumdown (Xlist[i]-meandown)**2 Xlist[i]-meandown Xlist[i] Xlist i meandown 2 sumup+= (Xlist[i]-meanup)**2 sumup (Xlist[i]-meanup)**2 Xlist[i]-meanup Xlist[i] Xlist i meanup 2 if sumdown<sumup:
  print(sumdown)
else:
  print (sumup) sumdown<sumup sumdown sumup print(sumdown) print sumdown print (sumup) print sumup min =10**5 10**5 min sumup = 0 0 sumup meanup = math.ceil(sum(Xlist)/N) math.ceil(sum(Xlist)/N) meanup Xlist = list(map(int,input().split())) list(map(int,input().split())) Xlist meandown = math.floor(sum(Xlist)/N) math.floor(sum(Xlist)/N) meandown sumdown+= (Xlist[i]-meandown)**2 (Xlist[i]-meandown)**2 sumdown sumdown=0 0 sumdown N = int(input()) int(input()) N sumup+= (Xlist[i]-meanup)**2 (Xlist[i]-meanup)**2 sumup
import math
N = int(input())
Xlist = list(map(int,input().split()))

min =10**5
meandown = math.floor(sum(Xlist)/N)
meanup = math.ceil(sum(Xlist)/N)
sumdown=0
sumup = 0
for i in range(len(Xlist)):
  sumdown+= (Xlist[i]-meandown)**2
  sumup+= (Xlist[i]-meanup)**2
  
if sumdown<sumup:
  print(sumdown)
else:
  print (sumup)