N=int(eval(input()))

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



import numpy as np

d = np.array(d)



print(( ( (np.sum(d))**2 - np.sum(d**2) ) // 2 ))

N=int(eval(input()))

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



cumsum = 0

for n in range(N):

    cumsum += d[n]

sub_cumsum = 0

ans = 0

for n in range(N):

    sub_cumsum += d[n]

    ans += d[n] * (cumsum-sub_cumsum)

print(ans)

N = int(eval(input()))
d = list(map(int, input().split()))
import numpy as np

d = np.array(d)
print((((np.sum(d)) ** 2 - np.sum(d**2)) // 2))

N = int(eval(input()))
d = list(map(int, input().split()))
cumsum = 0
for n in range(N):
    cumsum += d[n]
sub_cumsum = 0
ans = 0
for n in range(N):
    sub_cumsum += d[n]
    ans += d[n] * (cumsum - sub_cumsum)
print(ans)

-import numpy as np - -d = np.array(d) -print((((np.sum(d)) ** 2 - np.sum(d**2)) // 2)) +cumsum = 0 +for n in range(N): +    cumsum += d[n] +sub_cumsum = 0 +ans = 0 +for n in range(N): +    sub_cumsum += d[n] +    ans += d[n] * (cumsum - sub_cumsum) +print(ans)