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.

Difficulty: introductory

Starter code:

Solutions:
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)

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()))
s = 0

for i in range(N):
    for j in range(i+1, N):
        s += d[i] * d[j]

print(s)

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())
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()))
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())
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)

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()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += D[i] * D[j]
print(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())
d=list(map(int,input().split()))
s=0
for i in range(n):
    for j in range(i+1,n):
        s += d[i]*d[j]
print(s)

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())
d=list(map(int,input().split()))
d2=[m**2 for m in d]
print((sum(d)**2-sum(d2))//2)

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()))
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())
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)

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()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += d[i] * d[j]
print(ans)

# l,r,d =map(int, input().split()))
n = int(input())
d = list(map(int, input().split()))

# s = [map(int, input()) for i in range(3)]
ans =0

for i in range(0,n):
  
    for j in range(i+1,n):
       
        ans += d[i]*d[j]

print (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())
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)

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)

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()))
sum=0
for i in range(n-1):
  for j in range(i+1,n):
    sum+=d[i]*d[j]
print(sum)

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)

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=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)

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=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())
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):
        ans+=d[i]*d[j]
print(ans)

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 = 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()))

s = 0
for i in range(N):
    for j in range(i+1, N):
        s += d[i] * d[j]

print(s)

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

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

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())
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 = 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))))))


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)

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()

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 = [int(x) for x 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()))
s=0
for i in range(n-1):
    for j in range(i+1,n):
        s+=d[i]*d[j]
print(s)


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())
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())
d_list = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        ans += d_list[i] * d_list[j]

print(ans)


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

from itertools import combinations as cmb
import numpy as np

# たこ焼きの個数Nを取得
N = int(input())

# 各たこ焼きの味を取得
d = list(map(int, input().split()))

# たこ焼きの全組み合わせを作り、xとyに分離させる
x, y = np.array(list(cmb(d, 2))).T

# 体力の回復量の総和を求めて表示
print(np.sum(x*y))

n=int(input())
d=list(map(int,input().split()))
s=0
for i in range(n-1):
    for j in range(i+1,n):
        s+=d[i]*d[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 = 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)

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)))

# (x,y)
# (x,y)
# (x,y)

# 全組み合わせの転置行列を作成して、味x,味yに分ける
xy = tako_cmb.T

# (x,x,x)
# (y,y,y)

# xとyの積の総和を求める
result = np.sum(xy[0]*xy[1])

# 結果を出力する
print(result)

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)

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

ans = 0

for i in range(N):
  for j in range(N):
    if i != j:
      ans += d[i]*d[j]
      
print((ans//2))


#!/usr/bin/env python3
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()

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()

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)

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()))
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())
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)

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())
a = list(map(int, input().split()))
s = 0
for i in range(n):
  for j in range(i + 1, n):
    s += a[i] * a[j]
print(s)


N = int(input())
D = list(map(int, input().split()))
ans = 0

for i in range(len(D)-1):
    for j in range(i+1, len(D)):
        ans += D[i]*D[j]
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)

import itertools as it
# 入力
N = int(input())
d = list(map(int, input().split()))

# 2つの組み合わせの全パターンを取得する
k = list(it.combinations(d, 2))
# 組み合わせの掛け算をリストに詰めてsum
n = [a*b for a, b in k]

print(sum(n))

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

n=int(input())
d=list(map(int,input().split()))
sam=0

for i in range(n):
  for j in range(i+1,n): 
    sam=sam+(d[i]*d[j]) 
    

print(sam)

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())
lsd = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += lsd[i]*lsd[j]
print(ans)


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

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)


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())
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 = [int(x) for x in 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())

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)

#!/usr/bin/env python3
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())
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())
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()))

sum=0
for i in range(0,n):
    for j in range(i+1,n):
        sum+=d[i]*d[j]

print(sum)


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())
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)


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

c=0
for i in range(n-1):
    for j in range(i+1,n):
        c+=(d[i]*d[j])
print(c)

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())
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())
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)

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)


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())
d = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += d[i]*d[j]
print(ans)

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())
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())
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 = list(map(int,input().split()))

# dから2個選び、総和をとる
import itertools
rec = 0
for tako in itertools.combinations(d, 2):
    rec += tako[0]*tako[1]
print(rec)

N = int(input())
A = list(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 = [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())

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())
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 = 0
for i in range(N):
  for j in range(i+1, N):
    ans += d[i]*d[j]
    
print(ans)