n = int(eval(input()))

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

for p in range(max(X)+100):

    sum = 0

    for x in X:

        sum += ((x - p)**2)

    if p == 0:

        ans = sum

    if ans > sum:

        ans = sum

print(ans)
n = int(eval(input()))

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

for p in range(max(X)+1):

    sum = 0

    for x in X:

        sum += ((x - p)**2)

    if p == 0:

        ans = sum

    if ans > sum:

        ans = sum

print(ans)

n = int(eval(input()))
X = list(map(int, input().split()))
for p in range(max(X) + 100):
    sum = 0
    for x in X:
        sum += (x - p) ** 2
    if p == 0:
        ans = sum
    if ans > sum:
        ans = sum
print(ans)

n = int(eval(input()))
X = list(map(int, input().split()))
for p in range(max(X) + 1):
    sum = 0
    for x in X:
        sum += (x - p) ** 2
    if p == 0:
        ans = sum
    if ans > sum:
        ans = sum
print(ans)

-for p in range(max(X) + 100): +for p in range(max(X) + 1):