AtCoder Beginner Contest 143 - TAKOYAKI FESTIVAL 2019

It's now the season of TAKOYAKI FESTIVAL!
This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.
As is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \times y health points.
There are \frac{N \times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \frac{N \times (N - 1)}{2} values.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq N \leq 50
 - 0 \leq d_i \leq 100

-----Input-----
Input is given from Standard Input in the following format:
N
d_1 d_2 ... d_N

-----Output-----
Print the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.

-----Sample Input-----
3
3 1 2

-----Sample Output-----
11

There are three possible choices:
 - Eat the first and second takoyaki. You will restore 3 health points.
 - Eat the second and third takoyaki. You will restore 2 health points.
 - Eat the first and third takoyaki. You will restore 6 health points.
The sum of these values is 11.

Source: atcoder | Difficulty: EASY


Solutions:
n = int(input())
d = [int(di) for di in input().split()]
print(sum((d[i] * d[j] for i in range(n) for j in range(i + 1, n))))


n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(len(d) - 1):
	for k in range(i + 1, len(d)):
		ans += d[i] * d[k]
print(ans)


n = int(input())
l = [int(i) for i in input().split()]
s = 0
for i in range(n):
	for j in range(i + 1, n):
		s += l[j] * l[i]
print(s)


N = int(input())
A = list(map(int, input().split()))
s = sum(A) ** 2
for i in range(N):
	s -= A[i] ** 2
print(int(s / 2))


import itertools as itr
n = input()
d = map(int, input().split())
k = itr.combinations(d, 2)
sum_k = sum([a * b for (a, b) in k])
print(sum_k)


from itertools import permutations
n = int(input())
d = [int(i) for i in input().split()]
t = sum([i[0] * i[1] for i in permutations(d, 2)]) // 2
print(t)


(n, *d) = map(int, open(0).read().split())
print(sum((d[i] * d[j] for i in range(n) for j in range(i + 1, n))))


n = int(input())
s = input().split()
c = 0
d = 0
for num in s:
	c += int(num)
	d += int(num) ** 2
e = (c ** 2 - d) // 2
print(e)


n = int(input())
d = list(map(int, input().split()))
dd = [x ** 2 for x in d]
print((sum(d) ** 2 - sum(dd)) // 2)


n = int(input())
lst = list(map(int, input().split()))
x = 0
for i in range(n):
	x += lst[i] * sum(lst[i + 1:n])
print(x)


n = int(input())
d = list(map(int, input().split()))
ml = []
for i in range(n):
	for j in range(i + 1, n):
		ml.append(d[i] * d[j])
print(sum(ml))


N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		if i != j:
			ans += d[i] * d[j]
print(ans)


n = int(input())
a = [*map(int, input().split())]
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		ans += a[i] * a[j]
print(ans)


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


(n, *d) = map(int, open(0).read().split())
s = sum(d)
ans = 0
for i in d:
	ans += i * (s - i)
print(ans // 2)


a = int(input())
b = list(map(int, input().split()))
s = 0
for i in range(a):
	for j in range(i + 1, a):
		s += b[i] * b[j]
print(s)


n = int(input())
d = list(map(int, input().split()))
d2 = [m ** 2 for m in d]
print((sum(d) ** 2 - sum(d2)) // 2)


N = int(input())
dn = list(map(int, input().split()))
ans = 0
for i in range(N):
	for j in range(N):
		if i != j:
			ans += dn[i] * dn[j]
print(ans // 2)


N = int(input())
dlst = list(map(int, input().split()))
ans = 0
for i in range(len(dlst) - 1):
	k = dlst.pop()
	ans = ans + k * sum(dlst)
print(ans)


n = int(input())
d = list(map(int, input().split()))
ans = sum(d) ** 2
for i in d:
	ans -= i ** 2
print(ans // 2)


input()
A = list(map(int, input().split()))
b = 0
while A:
	a = A.pop(0)
	for i in A:
		b += i * a
print(b)


import itertools
n = int(input())
l = list(map(int, input().split()))
c = itertools.combinations(l, 2)
ans = sum((x * y for (x, y) in c))
print(ans)


n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
	for j in range(i + 1, n):
		ans += d[i] * d[j]
print(ans)


a = int(input())
b = [int(i) for i in input().split()]
ans = 0
for i in range(a):
	ans += b[i] * (sum(b) - b[i])
print(ans // 2)


n = int(input())
d = list(map(int, input().split()))
S = sum(d)
T = sum((x * x for x in d))
print((S * S - T) // 2)


n = int(input())
xlist = list(map(int, input().split()))
sum = 0
for i in range(n):
	for j in range(i + 1, n):
		sum += xlist[i] * xlist[j]
print(sum)


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

def hp():
	count = 0
	for i in range(N - 1):
		for j in range(i + 1, N):
			count = count + d[i] * d[j]
	return count
print(hp())


(n, *d) = map(int, open(0).read().split())
s = sum(d) ** 2
for v in d:
	s -= v ** 2
print(s // 2)


import numpy as np
import itertools as itr
N = int(input())
D = list(map(int, input().split()))
tako_cmb = np.array(list(itr.combinations(D, 2)))
xy = tako_cmb.T
result = np.sum(xy[0] * xy[1])
print(result)


N = int(input())
d = list(map(int, input().split()))
total = sum(d)
print(sum([(total - i) * i for i in d]) // 2)


import itertools
N = int(input())
D = list(map(int, input().split()))
res = 0
for (i, j) in itertools.combinations(D, 2):
	res += i * j
print(res)


N = int(input())
d = list(map(int, input().split()))
p = sum(d)
q = sum([pow(x, 2) for x in d])
print((pow(p, 2) - q) // 2)


import itertools
N = int(input())
a = itertools.combinations(list(map(int, input().split())), 2)
print(sum([i * j for (i, j) in a]))


N = int(input())
L = list(map(int, input().split()))
s = sum(L)
p = 0
for a in L:
	p += a * a
ans = (s * s - p) / 2
print(int(ans))


N = int(input())
D = list(map(int, input().split()))
ans = 0
for i in range(N):
	for j in range(i + 1, N):
		ans += D[i] * D[j]
print(ans)


n = int(input())
li = list(map(int, input().split()))
su = 0
for i in range(n):
	for j in range(i + 1, n):
		su += li[i] * li[j]
print(su)


n = int(input())
m = list(map(int, input().split()))
m2 = []
for j in m:
	m2.append(j * j)
print(int((sum(m) ** 2 - sum(m2)) / 2))


import itertools
n = int(input())
d = list(map(int, input().split()))
M = []
ans = 0
for v in itertools.combinations(d, 2):
	M.append(list(v))
for m in M:
	ans += m[0] * m[1]
print(ans)


n = int(input())
a = list(map(int, input().split()))
aa = 0
for i in a:
	x = i ** 2
	aa += x
print((sum(a) ** 2 - aa) // 2)


N = int(input())
D = list(map(int, input().split()))
print((sum(D) ** 2 - sum((d * d for d in D))) // 2)


(N, *D) = map(int, open(0).read().split())
print((sum(D) ** 2 - sum((d * d for d in D))) // 2)


N = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
	ans += l[i] * sum(l[i + 1:])
print(ans)


N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N):
	ans += sum(d[:i]) * d[i]
print(ans)


input()
D = list(map(int, input().split()))
s = sum(D)
ss = sum((d ** 2 for d in D))
print((s ** 2 - ss) // 2)


n = input()
d = list(map(int, input().split()))
diag = [x * x for x in d]
sumd = sum(d)
print((sumd ** 2 - sum(diag)) // 2)


N = int(input())
d = list(map(int, input().split()))
s = 0
for i in range(0, N):
	s += d[i] * sum(d[i + 1:N])
print(s)


n = int(input())
d = [int(x) for x in input().split()]
print((sum(d) ** 2 - sum([x ** 2 for x in d])) // 2)


input()
seq = [int(x) for x in input().split()]
ans = sum((x * y for (i, x) in enumerate(seq) for y in seq[i + 1:]))
print(ans)


from itertools import *
N = int(input())
D = list(map(int, input().split()))
print(sum((x * y for (x, y) in combinations(D, 2))))


N = int(input())
L = list(map(int, input().split()))
sum = 0
for x in range(N):
	for y in range(x + 1, N):
		sum += L[x] * L[y]
print(sum)


N = int(input())
d = [int(x) for x in input().split()]
f = sum(d)
s = 0
for i in d:
	s += i * (f - i)
print(s // 2)


n = int(input())
d = list(map(int, input().split()))
dsum = sum(d)
ans = 0
for c in d:
	ans += c * (dsum - c)
print(ans // 2)


import itertools
total = 0
recovery = 0
n = int(input())
di = list(map(int, input().split()))
for x in itertools.combinations(di, 2):
	recovery = x[0] * x[1]
	total += recovery
print(total)


from itertools import combinations
input()
print(sum((x * y for (x, y) in combinations([int(i) for i in input().split()], 2))))


from itertools import combinations
n = int(input())
d = list(map(int, input().split()))
ans = 0
d = combinations(d, 2)
for (i, j) in d:
	ans += i * j
print(ans)


N = int(input())
d = list(map(int, input().split()))
import itertools
rec = 0
for tako in itertools.combinations(d, 2):
	rec += tako[0] * tako[1]
print(rec)


N = int(input())
d = list(map(int, input().split()))
S_d = sum(d)
ans = 0
for i in d:
	ans += i * (S_d - i)
print(int(ans / 2))


import itertools
(n, *d) = map(int, open(0).read().split())
print(sum((a * b for (a, b) in itertools.combinations(d, 2))))


def ans143(N: int, d: str):
	d = list(map(int, d.split()))
	ans_count = 0
	while len(d) >= 2:
		for i in range(len(d) - 1):
			ans_count += d[0] * d[i + 1]
		del d[0]
	return ans_count
N = int(input())
d = input()
print(ans143(N, d))


N = int(input())
D = list(map(int, input().split()))
print((sum(D) ** 2 - sum(list(map(lambda x: x ** 2, D)))) // 2)


n = int(input())
arr = [int(x) for x in input().split()]
f = sum(arr)
s = 0
for i in arr:
	s += i * (f - i)
print(s // 2)


n = int(input())
d = list(map(int, input().split()))
s = sum(d)
ans = 0
for i in d:
	s -= i
	ans += s * i
print(ans)


n = int(input())
a = list(map(int, input().split()))
print(sum([a[i] * a[j] for i in range(n) for j in range(i + 1, n)]))


import itertools
N = int(input())
d = list(map(int, input().split()))
c = [x * y for (x, y) in itertools.combinations(d, 2)]
print(sum(c))


input()
d = list(map(int, input().split()))
ans = (sum(d) ** 2 - sum((di ** 2 for di in d))) // 2
print(ans)


N = int(input())
d = list(map(int, input().split()))
sq = [di ** 2 for di in d]
print((sum(d) ** 2 - sum(sq)) // 2)


def main():
	from itertools import combinations
	_ = int(input())
	d = [int(x) for x in input().split()]
	print(sum([a * b for (a, b) in combinations(d, 2)]))

def __starting_point():
	main()
__starting_point()


n = int(input())
b = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
	ans += b[i] * sum(b[i + 1:])
print(ans)


i = input
n = int(i())
l = [int(_) for _ in i().split()]
ans = 0
for _ in range(n):
	ans += l[_] * sum(l[_ + 1:])
print(ans)


n = int(input())
d = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	ans += d[i] * sum(d[i + 1:])
print(ans)


import itertools as it
N = int(input())
d = list(map(int, input().split()))
k = list(it.combinations(d, 2))
n = [a * b for (a, b) in k]
print(sum(n))


n = int(input())
d = list(map(int, input().split()))
p = sum(d)
r = 0
for i in range(n):
	r += (p - d[i]) * d[i]
print(r // 2)


t = input()
d = list(map(int, input().split()))
cure = 0
for i in range(len(d)):
	for s in range(i + 1, len(d)):
		cure += d[i] * d[s]
print(cure)


N = int(input())
d = list(map(int, input().split()))
print((sum(d) ** 2 - sum(map(lambda x: x ** 2, d))) // 2)


N = int(input())
d = list(map(int, input().split()))
s = sum(d)
ans = s ** 2
for i in range(N):
	ans -= d[i] ** 2
print(ans // 2)


n = int(input())
d = list(map(int, input().split()))
print((sum(d) ** 2 - sum(map(lambda x: x ** 2, d))) // 2)


N = int(input())
A = [int(a) for a in input().split()]
print((sum(A) ** 2 - sum([a ** 2 for a in A])) // 2)


n = int(input())
l = list(map(int, input().split()))
(s, res) = (l[0], 0)
for i in range(1, n):
	res += s * l[i]
	s += l[i]
print(res)


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


N = int(input())
d = [int(i) for i in input().split()]
X = sum([i * i for i in d])
print((sum(d) ** 2 - X) // 2)


b = input()
a = list(map(int, input().split()))
s = sum(a)
an = 0
for i in a:
	an += (s - i) * i
print(an >> 1)


n = int(input())
d = list(map(int, input().split()))
s = 0
for i in range(n):
	for j in range(n):
		if i < j:
			s += d[i] * d[j]
print(s)


a = int(input())
b = list(map(int, input().split()))
c = sum(b)
d = [(c - x) * x for x in b]
e = sum(d)
print(int(e / 2))


n = int(input())
d = [int(i) for i in input().split()]
d1 = [i ** 2 for i in d]
s = sum(d)
ans = (s ** 2 - sum(d1)) // 2
print(ans)


a = int(input())
b = 0
c = list(map(int, input().split()))
for i in range(a):
	for k in range(a):
		b = b + c[i] * c[k]
for u in range(a):
	b = b - c[u] * c[u]
print(int(b / 2))


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
s1 = s * s
t = 0
for i in l:
	t += i * i
print((s1 - t) // 2)


(N, *D) = map(int, open(0).read().split())
s = 0
ans = 0
for i in range(1, len(D)):
	s += D[i - 1]
	ans += D[i] * s
print(ans)


from itertools import combinations as cmb
import numpy as np
N = int(input())
d = list(map(int, input().split()))
(x, y) = np.array(list(cmb(d, 2))).T
print(np.sum(x * y))


from itertools import combinations
n = int(input())
d = list(map(int, input().split()))
c = combinations(d, 2)
sumd = 0
for (x, y) in c:
	sumd += x * y
print(sumd)


n = int(input())
cur = res = 0
for e in map(int, input().split()):
	res += e * cur
	cur += e
print(res)


from itertools import combinations
n = int(input())
d = list(map(int, input().split()))
comb = combinations(d, 2)
res = 0
for (x, y) in comb:
	res += x * y
print(res)


n = int(input())
l = list(map(int, input().split()))
print(sum((l[i] * l[j] for i in range(n) for j in range(i))))


(N, *D) = map(int, open(0).read().split())
import itertools
print(sum((a * b for (a, b) in itertools.combinations(D, 2))))


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
ans = 0
for i in l:
	ans += (s - i) * i
print(ans // 2)


N = int(input())
d = list(map(int, input().split()))
t = 0
for i in range(N - 1):
	for k in range(i + 1, N):
		t += d[i] * d[k]
print(t)


n = int(input())
list = list(map(int, input().split()))
s = 0
for i in range(0, n - 1):
	s += list[i] * sum(list[i + 1:n])
print(s)


from itertools import *
input()
print(sum([n * m for (n, m) in combinations(map(int, input().split()), 2)]))


n = int(input())
d = list(map(int, input().split()))
tot = sum(d) ** 2
for i in range(n):
	tot -= d[i] ** 2
print(tot // 2)


n = input()
d = [int(i) for i in input().split()]
print((sum((i for i in d)) ** 2 - sum((i ** 2 for i in d))) // 2)


from itertools import combinations as C
N = int(input())
d = list(map(int, input().split()))
D = list(C(d, 2))
ans = 0
for i in D:
	ans += i[0] * i[1]
print(ans)


N = int(input())
D = list(map(int, input().split()))
ANS = 0
for i in range(N):
	for j in range(N):
		if i >= j:
			continue
		ANS = ANS + D[i] * D[j]
print(ANS)


n = int(input())
d = list(map(int, input().split()))
s = 0
a = sum(d)
for i in d:
	s += i * (a - i)
print(int(s / 2))


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


n = int(input())
d = list(map(int, input().split()))
d_sum = sum(d)
sq = 0
for i in range(n):
	sq += d[i] ** 2
print((d_sum ** 2 - sq) // 2)


(_, d) = open(0)
a = b = 0
for d in d.split():
	d = int(d)
	a += d * d
	b += d
print(b ** 2 - a >> 1)


N = int(input())
d = list(map(int, input().split(' ')))
print(sum([d[i] * d[j] for i in range(N) for j in range(i + 1, N)]))


N = int(input())
d = list(map(int, input().split()))
kaifuku = 0
for i in range(N):
	for j in range(i + 1, N):
		kaifuku += d[i] * d[j]
print(kaifuku)


N = int(input())
D = list(map(int, input().split()))
ans = 0
for n in range(N - 1):
	ans += sum(D[n] * D[n + 1:])
print(ans)


N = int(input())
D = list(map(int, input().split()))
res = 0
for i in range(N):
	res += sum(D[i + 1:]) * D[i]
print(res)


N = int(input())
D = list(map(int, input().split()))
Sum = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		A = D[i] * D[j]
		Sum += A
print(Sum)


n = int(input())
d = list(map(int, input().split()))
sd = sum(d)
t = [x * x for x in d]
st = sum(t)
print((sd * sd - st) // 2)


import itertools
n = int(input())
d = list(map(int, input().split()))
print(sum([x * y for (x, y) in itertools.combinations(d, 2)]))


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


n = int(input())
d = list(map(int, input().split()))
cnt = 0
dd = sum(d)
for i in d:
	cnt += i * (dd - i)
print(cnt // 2)


N = int(input())
D = list(map(int, input().split()))
S = sum(D)
C = 0
for i in D:
	C += i * (S - i)
print(int(C / 2))


import itertools
n = int(input())
Tako = list(map(int, input().split()))
ans = 0
for (x, y) in itertools.combinations(Tako, 2):
	ans += x * y
print(ans)


a = int(input())
b = list(map(int, input().split()))
c = 0
for i in range(a):
	for j in range(i):
		c += b[i] * b[j]
print(c)


n = int(input())
s = list(map(int, input().split()))
z = 0
for i in range(n):
	for j in range(i + 1, n):
		z += s[i] * s[j]
print(z)


N = int(input())
L = list(map(int, input().split()))
S = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		S += L[i] * L[j]
print(S)


n = int(input())
d = list(map(int, input().split()))
sm = 0
for i in range(len(d) - 1):
	for j in range(i + 1, len(d)):
		sm += d[i] * d[j]
print(sm)


N = int(input())
d = [int(x) for x in input().split()]
print((pow(sum(d), 2) - sum([pow(x, 2) for x in d])) // 2)


import itertools
n = int(input())
a = list(map(int, input().split()))
pattern = itertools.combinations(a, 2)
total = 0
for (i, j) in pattern:
	total += i * j
print(total)


N = int(input())
d = [int(n) for n in input().split()]
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		ans += d[i] * d[j]
print(ans)


N = int(input())
A = list(map(int, input().split()))
p = sum(A)
q = sum([a * a for a in A])
print((p * p - q) // 2)


input()
l = list(map(int, input().split()))
a = 0
for _ in l:
	a += _ * (sum(l) - _)
print(a // 2)


N = int(input())
d = list(map(int, input().split()))
ret = 0
for di in d:
	ret += di * sum(d) - di ** 2
print(ret // 2)


N = int(input())
O = list(map(int, input().split()))
t = 0
for i in range(N):
	for j in range(i):
		t += O[i] * O[j]
print(t)


N = int(input())
d = list(map(int, input().split()))
print(sum((d[x] * d[y] for x in range(N) for y in range(x, N) if x != y)))


N = int(input())
d = list(map(int, input().split()))
S = [0]
for i in range(N):
	S.append(S[i] + d[i])
ans = 0
for j in range(N):
	ans += d[-j - 1] * S[-j - 2]
print(ans)


n = int(input())
D = list(map(int, input().split()))
A = sum(D)
ans = 0
for d in D:
	A -= d
	ans += A * d
print(ans)


n = int(input())
a = list(map(int, input().split()))
p = sum(a)
q = sum([x * x for x in a])
print((p * p - q) // 2)


N = int(input())
b = list(map(int, input().split()))
c = []
for i in range(N):
	c.append(b[i] ** 2)
print((sum(b) ** 2 - sum(c)) // 2)


n = int(input())
oisi = list(map(int, input().split()))
total = 0
for i in range(0, n - 1):
	for j in range(i + 1, n):
		total += oisi[i] * oisi[j]
print(total)


n = int(input())
l = list(map(int, input().split()))
s = 0
for (i, j) in enumerate(l):
	for k in l[i + 1:]:
		s += j * k
print(s)


N = int(input())
A = list(map(int, input().split()))
B = sum(A)
count = 0
for i in range(N):
	count += A[i] ** 2
print((B ** 2 - count) // 2)


import itertools
N = int(input())
d = list(map(int, input().split()))
lst = list(itertools.combinations(d, 2))
total = 0
for n in lst:
	c = n[0] * n[1]
	total += c
print(total)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(500000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

def ceil(a, b):
	return (a + b - 1) // b

def sum_of_arithmetic_progression(s, d, n):
	return n * (2 * s + (n - 1) * d) // 2

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	g = gcd(a, b)
	return a / g * b

def solve():
	N = int(input())
	D = list(map(int, input().split()))
	ans = 0
	for i in range(N):
		for j in range(i + 1, N):
			ans += D[i] * D[j]
	print(ans)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


n = int(input())
lis = list(map(int, input().split()))
ans = 0
for i in range(0, n - 1):
	for t in range(i + 1, n):
		con = lis[i] * lis[t]
		ans += con
print(ans)


n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n):
	for j in range(i):
		ans += A[i] * A[j]
print(ans)


n = int(input())
a = list(map(int, input().split()))
p = 0
for i in range(n - 1):
	for j in range(i + 1, n):
		p += a[i] * a[j]
print(p)


n = int(input())
d = list(map(int, input().split()))
a = 0
for i in range(n):
	for j in range(n):
		if i != j:
			a += d[i] * d[j]
print(a // 2)


n = int(input())
a = [int(x) for x in input().split()]
res = 0
for i in range(n):
	for j in range(i + 1, n):
		res += a[i] * a[j]
print(res)


(N, *D) = map(int, open(0).read().split())
i = 0
A = 0
while i < N:
	j = i + 1
	while j < N:
		A += D[i] * D[j]
		j += 1
	i += 1
print(A)


n = int(input())
a = list(map(int, input().split()))
sqsum = sum((i * i for i in a))
ans = (sum(a) * sum(a) - sqsum) // 2
print(ans)


input()
(*l,) = map(int, input().split())
print((pow(sum(l), 2) - sum([pow(x, 2) for x in l])) // 2)


n = int(input())
d = list(map(int, input().split()))
a = sum(d) ** 2
b = sum((d[i] ** 2 for i in range(n)))
print((a - b) // 2)


N = int(input())
d = list(map(int, input().split()))
s = sum(d)
t = sum((d[i] ** 2 for i in range(0, N)))
print((s ** 2 - t) // 2)


(n, *a) = map(int, open(0).read().split())
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		ans += a[i] * a[j]
print(ans)


N = int(input())
D = list(map(int, input().split()))
from itertools import accumulate
print(sum(list((d * c for (d, c) in zip(D[1:], accumulate(D))))))


n = int(input())
d = list(map(int, input().split(' ')))
s = 0
s2 = 0
for x in d:
	s += x
	s2 += x * x
print((s * s - s2) // 2)


n = int(input())
l = list(map(int, input().split()))
su = 0
for i in l:
	su += i * sum(l) - i * i
print(int(su / 2))


n = int(input())
A = list(map(int, input().split()))
f = 0
for i in range(0, n - 1):
	for j in range(i + 1, n):
		f = f + A[i] * A[j]
print(f)


from itertools import combinations
from typing import List

def answer(n: int, d: List[int]) -> int:
	return sum((d[x] * d[y] for (x, y) in combinations(list(range(n)), 2)))

def main():
	n = int(input())
	d = list(map(int, input().split()))
	print(answer(n, d))

def __starting_point():
	main()
__starting_point()


N = int(input())
data = [int(x) for x in input().split()]
data2 = [x ** 2 for x in data]
print((sum(data) ** 2 - sum(data2)) // 2)


from itertools import combinations
input()
d = list(map(int, input().split()))
comb = combinations(d, 2)
dsum = 0
for (a, b) in comb:
	dsum += a * b
print(dsum)


n = int(input())
l = list(map(int, input().split()))
print(sum((l[i] * x for i in range(len(l) - 1) for x in l[i + 1:])))


n = int(input())
l = [int(i) for i in input().split()]
s = sum(l)
ss = s * s
sq = sum((i * i for i in l))
print((ss - sq) // 2)


N = int(input())
d_list = list(map(int, input().split()))
ans = 0
for i in range(N):
	for j in range(i):
		ans += d_list[i] * d_list[j]
print(ans)


N = int(input())
D = [int(_) for _ in input().split()]
S = sum(D)
W = [(S - d) * d for d in D]
print(sum(W) // 2)


gomi = input()
tako = [int(i) for i in input().split()]
print(int((sum(tako) ** 2 - sum([i ** 2 for i in tako])) / 2))


N = int(input())
d = list(map(int, input().split()))
sum1 = sum(d) ** 2
sum2 = sum([i * i for i in d])
print(int((sum1 - sum2) / 2))


N = int(input())
d_s = list(map(int, input().split()))
S = sum(d_s)
print(sum(list(map(lambda x: (S - x) * x, d_s))) // 2)


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


import itertools
print(sum([i * j for (i, j) in itertools.combinations([int(i) for i in (input(), input())[1].split()], 2)]))


(_, d) = open(0)
(*d,) = map(int, d.split())
print(sum(d) ** 2 - sum((i ** 2 for i in d)) >> 1)


input()
s = t = 0
for i in map(int, input().split()):
	s += i * i
	t += i
print(t * t - s >> 1)


n = int(input())
t = [int(x) for x in input().split()]
t2 = [x * x for x in t]
print((sum(t) ** 2 - sum(t2)) // 2)


import itertools

def resolve():
	n = int(input())
	d = tuple(map(int, input().split()))
	ans = 0
	for a in itertools.combinations(d, 2):
		ans += a[0] * a[1]
	print(ans)
resolve()


n = int(input())
d = list(map(int, input().split()))
sum1 = sum(d)
sum2 = 0
for i in d:
	sum2 += i ** 2
print((sum1 ** 2 - sum2) // 2)


N = int(input())
d = [int(x) for x in input().split()]
result = 0
for i in range(N):
	for j in range(i + 1, N):
		result += d[i] * d[j]
print(result)


N = int(input())
L = list(map(int, input().split()))
a = 0
for i in L:
	a = a + i ** 2
b = sum(L)
print((b ** 2 - a) // 2)


n = int(input())
d = list(map(int, input().split()))
r = 0
for i in range(n - 1):
	r += d[i] * sum(d[i + 1:])
print(r)


n = int(input())
arr = list(map(int, input().split()))
ans = 0
tmp = sum(arr)
for val in arr:
	ans += val * (tmp - val)
print(ans // 2)


import itertools
N = int(input())
D = list(map(int, input().split()))
takocombi = list(itertools.combinations([i for i in range(N)], 2))
ans = 0
for h in range(len(takocombi)):
	ans += D[takocombi[h][0]] * D[takocombi[h][1]]
print(ans)


n = int(input())
d = list(map(int, input().split()))
d2 = d[:]
total = 0
for i in range(len(d)):
	for j in range(i, len(d2)):
		if i != j:
			total += d[i] * d[j]
print(total)


N = int(input())
D = list(map(int, input().split()))
ans = 0
for i in range(N):
	tako1 = D[i]
	for j in range(0, i):
		tako2 = D[j]
		ans += tako1 * tako2
	for j in range(i + 1, N):
		tako2 = D[j]
		ans += tako1 * tako2
print(ans // 2)


N = int(input())
d = [int(i) for i in input().split()]
ans = sum(d) ** 2
for dd in d:
	ans -= dd ** 2
print(ans // 2)


N = int(input())
d = list(map(int, input().split()))
sumd = sum(d)
d_2 = sum([i * i for i in d])
print((sumd * sumd - d_2) // 2)