import sys

input = sys.stdin.readline



N = int(eval(input()))

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



res = 0

for x in range(0, N-1):

	for y in range(x+1, N):

		res += vD[x] * vD[y]



print(res)

N = int(eval(input()))

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



res = 0

cs = 0

for a in vA:

  res += cs * a

  cs += a

print(res)

import sys

input = sys.stdin.readline
N = int(eval(input()))
vD = list(map(int, input().split()))
res = 0
for x in range(0, N - 1):
    for y in range(x + 1, N):
        res += vD[x] * vD[y]
print(res)

N = int(eval(input()))
vA = list(map(int, input().split()))
res = 0
cs = 0
for a in vA:
    res += cs * a
    cs += a
print(res)

-import sys - -input = sys.stdin.readline -vD = list(map(int, input().split())) +vA = list(map(int, input().split())) -for x in range(0, N - 1): -    for y in range(x + 1, N): -        res += vD[x] * vD[y] +cs = 0 +for a in vA: +    res += cs * a +    cs += a