n = int(input())
x = [int(i) for i in input().split()]
ave = sum(x) // n
ansl = 0
ansr = 0

for i in x:
    ansl += pow(i - ave, 2)
    ansr += pow(i - ave - 1, 2)

print(min([ansl, ansr])) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i x = [int(i) for i in input().split()] x [int(i) for i in input().split()] ave = sum(x) // n ave sum(x) // n sum(x) sum x n ansl = 0 ansl 0 ansr = 0 ansr 0 for i in x:
    ansl += pow(i - ave, 2)
    ansr += pow(i - ave - 1, 2) i x ansl += pow(i - ave, 2) ansl pow(i - ave, 2) pow i - ave i ave 2 ansr += pow(i - ave - 1, 2) ansr pow(i - ave - 1, 2) pow i - ave - 1 i - ave i ave 1 2 print(min([ansl, ansr])) print min([ansl, ansr]) min [ansl, ansr] ansl ansr n = int(input()) int(input()) n ansr += pow(i - ave - 1, 2) pow(i - ave - 1, 2) ansr x = [int(i) for i in input().split()] [int(i) for i in input().split()] x ansl += pow(i - ave, 2) pow(i - ave, 2) ansl ave = sum(x) // n sum(x) // n ave ansl = 0 0 ansl ansr = 0 0 ansr
n = int(input())
x = [int(i) for i in input().split()]
ave = sum(x) // n
ansl = 0
ansr = 0

for i in x:
    ansl += pow(i - ave, 2)
    ansr += pow(i - ave - 1, 2)

print(min([ansl, ansr]))