n = int(eval(input()))

ds = [int(x) for x in input().split()]

ds2 = [x*x for x in ds]

s = sum(ds)

print((int((sum(ds * s) - sum(ds2)) / 2 )))
n = int(eval(input()))

ds = [int(x) for x in input().split()]

ds2 = [x*x for x in ds]

s = 0

s2 = 0

for i in range(n):

  s += ds[i]

  s2 += ds2[i]

ss = 0

for i in range(n):

  ss += ds[i] * s



print(((ss - s2) // 2))
n = int(eval(input()))
ds = [int(x) for x in input().split()]
ds2 = [x * x for x in ds]
s = sum(ds)
print((int((sum(ds * s) - sum(ds2)) / 2)))

n = int(eval(input()))
ds = [int(x) for x in input().split()]
ds2 = [x * x for x in ds]
s = 0
s2 = 0
for i in range(n):
    s += ds[i]
    s2 += ds2[i]
ss = 0
for i in range(n):
    ss += ds[i] * s
print(((ss - s2) // 2))

-s = sum(ds) -print((int((sum(ds * s) - sum(ds2)) / 2))) +s = 0 +s2 = 0 +for i in range(n): +    s += ds[i] +    s2 += ds2[i] +ss = 0 +for i in range(n): +    ss += ds[i] * s +print(((ss - s2) // 2))