Problem:
 Score : 200 points    Problem Statement 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 1 3
3 1 2      Sample Output 1 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 .       Sample Input 2 7
5 0 7 8 3 3 2      Sample Output 2 312

Solution (Python):
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)

Solution (Python):
n = int(raw_input())
a = map(int,raw_input().split())
ans = 0
for i in xrange(n-1):
  for j in xrange(i+1,n):
    ans += a[i]*a[j]
print ans

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

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

Solution (Python):
N = int(input())
D = [int(x) for x in 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)

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

Solution (Python):
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)

Solution (Python):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

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

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
takoyaki = [ int(v) for v in input().split() ]

ans = 0
for i in range(n):
    for j in range(n):
        if i != j:
            ans += takoyaki[i]*takoyaki[j]
print(ans//2)

Solution (Python):
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)

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

cnt = 0
for i in range(n):
	for j in range(n):
		if j == i:
			break
		cnt += d[i]*d[j]

print(cnt)

Solution (Python):


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)

Solution (Python):

from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from random import randint
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
sys.setrecursionlimit(9999)
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
N = 5001
 
'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''


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


BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0
 
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
 
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)
 
	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
l = list(map(int, input().split()))

cnt = 0
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        cnt += l[i]*l[j]
print(cnt//2)

Solution (Python):
import itertools
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
ans = 0
for i,j in itertools.combinations(range(N), 2):
  ans += A[i]*A[j]
print(ans)

Solution (Python):
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)

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    ds = LI()
    ans = 0
    c = 0
    for i in range(n):
        for j in range(n):
            if i >= j:
                continue
            ans += ds[i] * ds[j]
            c += 1
    assert c == n*(n-1)/2
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
d = list(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)

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

count = 0
for i in range(n):
    for j in range(i):
        count += d[i]*d[j]
print(count)

Solution (Python):
N = int(input())

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

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

print(sum)

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

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

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

Solution (Python):
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


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


    
            
    

    

    

if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
d = [int(x) for x in input().split()]
c = 0
for i in range(len(d)):
  for j in range(len(d)):
    if i != j:
      c += d[i]*d[j]
    
print(int(c/2))

Solution (Python):
N = int(input())
D = [int(d) for d in input().split()]
s = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        s += D[i] * D[j]

print(s)

Solution (Python):
from itertools import permutations
n=int(input())
d=[int(i) for i in input().split()]

ans=0
for i,j in permutations(d,2):
    ans+=i*j
print(ans//2)

Solution (Python):
from itertools import combinations
n=int(input())
s=0
d=[int(i) for i in input().split()]
for i,j in combinations(d,2):
    s+=i*j

print(s)

Solution (Python):
import sys
input = sys.stdin.buffer.readline
N = int(input())
d =list(map(int, input().split()))
res = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    res += d[i] * d[j]
print(res)

Solution (Python):
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)

Solution (Python):
N = int(input())
ds = list(map(int, input().split()))

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline


def main():
    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)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
ans = 0
for i in range(n):
  ans += a[i] * (s-a[i])
print(ans//2)

Solution (Python):
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)

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

Solution (Python):
def main():
    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)


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
D = list(map(int, input().split()))

ans = 0

for i in range(n):
    a = D[i]
    for j in range(i + 1, n):
        b = D[j]
        ans += a * b
print(ans)

Solution (Python):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
d = MAP()
ans=0

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

print(ans)

Solution (Python):
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
d = inputs()
ans = 0
for i in range(N):
  for j in range(i+1,N):
    ans+=d[i]*d[j]
print(ans)

Solution (Python):
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)

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

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

print(ans)

Solution (Python):
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)

Solution (Python):
from itertools import combinations
N = int(input())
D = list(map(int, input().split()))
ans = sum(a*b for a, b in combinations(D, 2))
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





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)

Solution (Python):
from itertools import combinations
N = int(input())
D = list(map(int,input().split()))

print(sum(a*b for a,b in combinations(D,2)))

Solution (Python):
N= int(input())
d = list(map(int,input().split(' ')))

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

Solution (Python):
N = int(input())

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

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

print(goukei)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    for a, b in combinations(A, 2):
        ans += a*b
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):
nm = lambda : map(int,input().split())
nl = lambda : list(nm())

n = int(input())
l = nl()
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans += l[i]*l[j]
print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
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)

Solution (Python):
n = int(input())
ds = list(map(int, input().split()))
sm = 0
for i in range(n):
    for j in range(i+1, n):
        d1, d2 = ds[i], ds[j]
        sm += d1 * d2
print(sm)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
total=0

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

print(total)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
acc = 0
lenA = len(A)
for i in range(lenA):
    for j in range(i+1, lenA):
        acc += A[i]*A[j]
print(str(acc))

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
d = list(li())

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

print(ans)

Solution (Python):
def main():
	import sys
	input = sys.stdin.readline
	
	n = int(input())
	arr = list(map(int, input().split()))
	kek = [sum(arr[:i + 1]) for i in range(n)]
	
	ans = 0
	for i in range(1, n):
		ans += arr[i] * kek[i - 1]
	
	print(ans)
	
	return 0

main()

Solution (Python):
from itertools import combinations
N = int(input())
D = [int(i) for i in input().split()]
print(sum([x * y for x, y in combinations(D, 2)]))

Solution (Python):
n = int(input())
dd = list(map(int,input().split()))

count = 0
for i in range(len(dd)):  
  for j in range(i+1,len(dd)):    
    count += dd[i]*dd[j]

print(count)

Solution (Python):
N = int(input())

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

ans = 0
for i in range(len(D)):
    for j in range(len(D)):
        if i==j:
            continue
        ans += D[i]*D[j]

print(ans//2)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
from itertools import combinations
N = int(input())
D = list(map(int, input().split()))
print(sum(d1*d2 for d1, d2 in combinations(D, 2)))

Solution (Python):
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)

Solution (Python):
N = int(input())
ds = list(map(int, input().strip().split()))

total = 0
for i in range(N):
	for j in range(i + 1, N):
		total += ds[i] * ds[j]
print(total)

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

total = sum(d)

ans = 0
for i in d:
    ans += (total - i) * i

ans //= 2

print (ans)

Solution (Python):
import sys
input=sys.stdin.readline
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)

Solution (Python):
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)

Solution (Python):
import sys
input = sys.stdin.readline

from itertools import combinations


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

    ans = 0
    for pat in combinations(d, 2):
        ans += pat[0] * pat[1]

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
d = [int(i) for i in input().split()]

s = 0
for i in range(n):
    for j in range(i+1, n):
        if i == j:
            continue
        s += d[i] * d[j]
print(s)

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

Solution (Python):
N = int(input())
D = [int(d) for d 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)

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

print(s)

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
nums = getList()
ans = 0
for i, num in enumerate(nums):
    for j, num2 in enumerate(nums[i+1:]):
        ans += num * num2


print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict


def getlist():
	return list(map(int, input().split()))


def main():
	N = int(input())
	d = getlist()
	ans = 0
	for i in range(N):
		for j in range(i + 1, N):
			ans += d[i] * d[j]
	print(ans)
	


if __name__ == '__main__':
	main()

Solution (Python):
from itertools import combinations

n = int(input())
ddd = list(map(int, input().split()))
print(sum(d1 * d2 for d1, d2 in combinations(ddd, 2)))

Solution (Python):
N=int(input())
D=list(map(int,input().split()))
ans=0
for i,d1 in enumerate(D):
    for j,d2 in enumerate(D):
        if j>i:
            ans += d1*d2
print(ans)

Solution (Python):
N = int(input())
D = list(map(int, input().split()))

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

print(t)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
D =LI()
ret = 0
for i in range(n):
    for j in range(i + 1, n):
        ret += D[i] * D[j]


print(ret)

Solution (Python):
import sys
from itertools import combinations
n = int(input())
d_ls = [int(i) for i in sys.stdin.readline().split()]
res = 0
for combi in combinations(d_ls, 2):
    res += combi[0] * combi[1]
print(res)

Solution (Python):
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n = int(input())
Arr = get_array()
ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans+=Arr[i]*Arr[j]
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
D = read_ints()
ans = 0

from itertools import combinations

for x, y in combinations(D, 2):
    ans += x * y

print(ans)

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

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

Solution (Python):
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)))

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

Solution (Python):
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)

Solution (Python):


def main():
    N = int( input())
    ans = 0
    d = list( map( int, input().split()))
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            ans += d[i]*d[j]
    print(ans//2)
if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):


import sys
import math
import collections



n=int(input())




tmp = input().split()
d = list(map(lambda a: int(a), tmp))


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



print(sum)

Solution (Python):
N=int(input())
dlist=list(map(int,input().split()))

answer=0
for i in range(N-1):
  for j in range(i+1,N):
    answer+=dlist[i]*dlist[j]
    
print(answer)

Solution (Python):
import queue

"""
N = int(input())



A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
A = [int(i) for i in input().split()]
B = 0
for i in range(len(A)):
	for j in range(len(A)):
		if i< j:
			B += A[i]*A[j]
print(B)

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

sq=[di**2 for di in d]

print((sum(d)**2-sum(sq))//2)

Solution (Python):
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)

Solution (Python):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    num = int(input())
    s = list(map(int,input().split()))
    ans = 0
    for i in range(num - 1):
        for j in range(i + 1, num):
            ans += s[i] * s[j]

    print(ans)





if __name__ == '__main__':
    main()

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

d = nl()

ans = 0

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

print(ans)

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

Solution (Python):

import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

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

Solution (Python):
N = int(input())
Bs = list(map(int, input().split()))

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

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

print(score)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*D = map(int,read().split())

S = sum(D)
T = sum(x*x for x in D)

answer = (S*S-T)//2
print(answer)

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

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

print(ans)

Solution (Python):
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)

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

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

Solution (Python):
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)

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

Solution (Python):
import itertools
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


def read_is(n=1):
    return [read_i() for _ in range(n)]


n = int(input())
ls = read_i()
res = 0
for x, y in itertools.combinations(ls, 2):
    res += x * y
print(res)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

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

Solution (Python):
N = int(input())
ds = list(map(int, input().split()))

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

Solution (Python):
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)

Solution (Python):
n=int(input())
dlist=list(int(i) for i in input().split())

kotae=0

for i in range(n):
    for j in range(n):
        if i!=j:
            kotae+=dlist[i]*dlist[j]

print(kotae//2)

Solution (Python):



import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):
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)

Solution (Python):
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)