N = int(eval(input()))

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

Min = 1e10

for p in range(1,101):

    Min = min(Min,sum(list([(x-p)**2 for x in X])))

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

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

Min = 1e10

for p in range(1,101):

    Min = min(Min,sum([(x-p)**2 for x in X]))

print(Min)
N = int(eval(input()))
X = list(map(int, input().split()))
Min = 1e10
for p in range(1, 101):
    Min = min(Min, sum(list([(x - p) ** 2 for x in X])))
print(Min)

N = int(eval(input()))
X = list(map(int, input().split()))
Min = 1e10
for p in range(1, 101):
    Min = min(Min, sum([(x - p) ** 2 for x in X]))
print(Min)

-    Min = min(Min, sum(list([(x - p) ** 2 for x in X]))) +    Min = min(Min, sum([(x - p) ** 2 for x in X]))