N = int(eval(input()))

A = list(map(int, input().split()))

answer = 10 ** 9

for i in range(1,101):

    tmp = 0

    for a in A:

        tmp += abs(a-i) ** 2

    answer = min(answer,tmp)

print(answer)
N = int(eval(input()))

A = list(map(int, input().split()))

chushin = sum(A)//N

chushin_1 = sum(A)//N +1

answer = 0

answer_1 = 0

for a in A:

    answer += abs(a-chushin) ** 2

    answer_1 += abs(a-chushin_1) ** 2

print((min(answer,answer_1)))
N = int(eval(input()))
A = list(map(int, input().split()))
answer = 10**9
for i in range(1, 101):
    tmp = 0
    for a in A:
        tmp += abs(a - i) ** 2
    answer = min(answer, tmp)
print(answer)

N = int(eval(input()))
A = list(map(int, input().split()))
chushin = sum(A) // N
chushin_1 = sum(A) // N + 1
answer = 0
answer_1 = 0
for a in A:
    answer += abs(a - chushin) ** 2
    answer_1 += abs(a - chushin_1) ** 2
print((min(answer, answer_1)))

-answer = 10**9 -for i in range(1, 101): -    tmp = 0 -    for a in A: -        tmp += abs(a - i) ** 2 -    answer = min(answer, tmp) -print(answer) +chushin = sum(A) // N +chushin_1 = sum(A) // N + 1 +answer = 0 +answer_1 = 0 +for a in A: +    answer += abs(a - chushin) ** 2 +    answer_1 += abs(a - chushin_1) ** 2 +print((min(answer, answer_1)))