N = int(eval(input()))

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

cnt = 0

for i in range(N-1):

    for j in range(i+1,N):

        cnt += D[i]*D[j]

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

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

cnt = 0

for i in range(N):

    cnt += D[i]**2

tot = 0

for i in range(N):

    tot += D[i]

tot = tot**2

tot -= cnt

print((tot//2))
N = int(eval(input()))
D = list(map(int, input().split()))
cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        cnt += D[i] * D[j]
print(cnt)

N = int(eval(input()))
D = list(map(int, input().split()))
cnt = 0
for i in range(N):
    cnt += D[i] ** 2
tot = 0
for i in range(N):
    tot += D[i]
tot = tot**2
tot -= cnt
print((tot // 2))

-for i in range(N - 1): -    for j in range(i + 1, N): -        cnt += D[i] * D[j] -print(cnt) +for i in range(N): +    cnt += D[i] ** 2 +tot = 0 +for i in range(N): +    tot += D[i] +tot = tot**2 +tot -= cnt +print((tot // 2))