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



Sample input:
3
3 1 2


Sample output:
11

Submission status: Accepted

Solution code:
import itertools
import functools
import operator

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

sm = 0

for v in itertools.combinations(d,2):
    sm += functools.reduce(operator.mul, list(v))
print(sm)

Submission status: Accepted

Solution code:
# 初期入力
N =int(input())
D = (int(x) for x in input().split())

#
from itertools import combinations
# ["a", "b", "c"] から 2 つ選ぶ組み合わせをすべて列挙する
kaifukuryou =[]
for t in combinations(D, 2):
    kaifukuryou.append(t[0]*t[1])

print(sum(kaifukuryou))

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
from itertools import combinations
for tako in list(combinations(range(n),2)):
  tako = list(tako)
  ans += d[tako[0]]*d[tako[1]]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
li=list(map(int,input().split()))
le=int(n*(n-1)/2)
a=0
b=[]
c=[]
def three(n):
  return n*li[i]
for i in range(le):
  a=li[i+1:]
  c=list(map(three,a))
  b.append(c)
    
print(sum(sum(b,[])))

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
Sum=0
for i in range(len(D)):
    for j in range(i,len(D)):
        if i!=j:
        
            Sum+=D[i]*D[j]

print(Sum)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
p=-sum([i**2 for i in a])
for i in a:
    for j in a:
        p += i*j
print(p//2)

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int, input().split()))
s=0
t=0
for i in range(n):
	s+=S[i]
	t+=S[i]**2

ans = (s**2-t)//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
T = 0
for i in range(N):
	if i == N-1:
		break
	for j in range(i+1,N):
		T += d[i]*d[j]
print(T)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
d = list(map(int,input().split()))

l = list(itertools.combinations(d,2))
su = 0
for li in l:
  su+= li[0]*li[1]
print(su)

Submission status: Accepted

Solution code:
import math
n = int(input())
d = list(map(int,input().split()))
count = 0
#print(d)

for i in range(n):
    #count += 1
    for j in range(n):
        if i == j:
            count += 0
        else :
            count += d[i] * d[j]
print(math.floor(count/2))

Submission status: Accepted

Solution code:
def q2():
    from itertools import combinations
    N = int(input())
    D = [int(i) for i in input().split()]
    comb_d = combinations(D, 2)
    ans = 0
    for d in comb_d:
        ans += d[0] * d[1]
    print(ans)


if __name__ == '__main__':
    q2()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
a = 0
for k,v in itertools.combinations(l, 2):
  a += k*v
print(a)

Submission status: Accepted

Solution code:
import itertools
##print(ord("A"))
n = int(input())
box= list(map(int,input().split()))
ans = 0
for i in range(n):
    l = box.pop(i)
    #print(box)
    for j in range(n-1):
        #print(box,j)
        ans += l*box[j]
    box.insert(i,l)
print(ans//2)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

length_d = len(d)
S = 0
for i in range(length_d):
    for j in range(i+1, length_d):
        S += d[i] * d[j]

print(S)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()
d = i_l()

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

print(ans)

Submission status: Accepted

Solution code:
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


n=int(input())
d=LI()

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int, input().split()))

from collections import deque
q = deque(A)

anc = []
for i in range(N-1):
    d = q.popleft()
    for p in q:
        anc.append(p*d)
    
print(sum(anc))

Submission status: Accepted

Solution code:
import itertools

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

y=len(list(itertools.combinations(x,2)))
z=list(itertools.combinations(x,2))

s=0
for i in range(y):
  s+=z[i][0]*z[i][1]
  
print(s)

Submission status: Accepted

Solution code:
N=int(input())
D=[int(i) for i in input().split()]
a=[]
for s in range(N-1):
    for j in range(s+1,N):
        a.append(D[s]*D[j])
print(sum(a))

Submission status: Accepted

Solution code:
import itertools

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

cnt = 0

for v in itertools.combinations(d, 2):
	cnt += v[0] * v[1]

print(cnt)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    d = list(map(int, input().split()))
    res = 0
    for i in combinations(d, 2):
        i = list(i)
        res += i[0] * i[1]
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
D=[int(_) for _ in input().split()]
sum=0
for i in range(n-1):
    for j in range(i+1,n):
        sum+=D[i]*D[j]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

sum = 0

for i in range(N):
    for j in range(N):
        if i == j : continue
        else:
            sum += D[i]*D[j]

print(int(sum/2))

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d_sum = sum(d)
d_dim = 0
ans = 0
for x in d:
    d_dim += x
    ans += x * (d_sum - d_dim)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
tako = list(map(int, input().split()))

from itertools import combinations

ans = 0
for _ in list(combinations(tako,2)):
  _ = list(_)
  ans = ans + _[0]*_[1]
  
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
c = list(map(int, input().split()))
point=0
for i in range(n):
  for j in range(i+1,n):
  	point += c[i] * c[j]

print(point)

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
from itertools import accumulate as acc
import copy as cp
import operator as op


n=ri()
d=rli()
temp=0
df=cp.deepcopy(d)
s=list(acc(df))
for i in range(1,n):
  temp+=s[i-1]*d[i]


print(temp)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

sum = 0
for i in range(n):
    for j in range(n):
        sum += D[i]*D[j]
for i in range(n):
    sum -= D[i]**2
    
sum = sum//2
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
import itertools
L = list(itertools.combinations(d,2))
s = 0
for i in range(len(L)):
    s += L[i][0]*L[i][1]
print(s)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
for x in range(N-1):
    for y in range(x+1, N):
        ans += d[x] * d[y]
print(ans)

Submission status: Accepted

Solution code:
import math
import itertools
n = int(input())
a_ls = list(map(int, input().split()))

index_ls = list(range(n))
c = itertools.combinations(index_ls, 2)
c = list(c)

ans = 0
for i in range(len(c)):
    recover = a_ls[c[i][0]] * a_ls[c[i][1]]
    ans += recover
print(ans)

Submission status: Accepted

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

sum = 0

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

sum = sum // 2

print(sum)

Submission status: Accepted

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

result = 0

for i in range(N):
    for j in range(N):
        if i != j:
            result += d[i] * d[j]

result = result // 2

print(result)

Submission status: Accepted

Solution code:
import math
import io

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

count = 0

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for x in range(n-1):
    #print(x, d[x], "d[x]" )
    for y in range(1,n - x):
        #print(y + x,"d[y+x]", d[y+x])
        ans += d[x] * (d[y+x])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(len(D)):
    num = D[i]
    for j in range(i+1, len(D)):
        ans += num * D[j]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

total = 0
for i in range(N):
  d = d_lst[:i] + d_lst[i+1:] # iを除いたリスト
  total += sum(d_lst[i] * d for d in d_lst[:i] + d_lst[i+1:])
print(total//2)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
d=list(map(int,input().split()))

p=itertools.permutations(d,2)

total=0
for i in p:
    total+=i[0]*i[1]
print(total//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
count =0
count1=0
for i in range(n):
    for j in range(n):
        if i ==j:
            count1 +=1
        else:
            count += d[i]*d[j]

print(int(count/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
d = list(map(int, input().split()))
combination_takoyaki = list(itertools.combinations(d, 2))
takoyaki = []
for i in combination_takoyaki:
    i_1 = i[0]
    i_2 = i[1]
    power = i_1 * i_2
    takoyaki.append(power)
takoyaki_power = sum(takoyaki)
print(takoyaki_power)

Submission status: Accepted

Solution code:
import math
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
ds=LI()
#print(ds)
D=sum(ds)
def sqr(x):
    return x*x
dds=list(map(sqr, ds))
#print(dds)
sigma=sum(dds)
ans=(D*D-sigma)/2
print(int(ans))

Submission status: Accepted

Solution code:
import math
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
ds=LI()
#print(ds)
D=sum(ds)
def sqr(x):
    return x*x
dds=[]
for d in ds:
    dds.append(d*d)
#print(dds)
sigma=sum(dds)
ans=(D*D-sigma)/2
print(int(ans))

Submission status: Accepted

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

def delicious(x: int, y: int) -> int:
    delicious = x * y
    return delicious

total = 0
for i in range(len(d)):
    for j in range(i + 1, len(d)):
        total += delicious(d[i], d[j])

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
ans_list = []
result = 0
ans_list = input().split()
ans_list2 = ans_list.copy()
for i in range(a-2):
    ans_list2.pop(0)
    for p in range(a-1 -i):
        result += int(ans_list[i]) * int(ans_list2[p])
    
result += int(ans_list[a-1]) * int(ans_list[a-2])
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import *
from collections import *


INF = float('inf')


def main():
    N = int(input())
    D = list(map(int, input().split()))

    pairs = list(permutations(D, 2))

    total = 0
    for pair in pairs:
        total += pair[0] * pair[1]

    total = total // 2
    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
N = int(input())
d = list(map(int,input().split()))

ans = 0

for v in itertools.combinations(d,2):
    ans = ans + (list(v)[0] * list(v)[1])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = input().split()
d = [int(x) for x in d]

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

Submission status: Accepted

Solution code:
import itertools

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

out = 0
for i in list(itertools.combinations(d, 2)):
    out += i[0] * i[1]

print(out)

Submission status: Accepted

Solution code:
HP=0
r=0
n=int(input())
d=list(map(int,input().split()))
for x in range(n):
    for y in range(n):
        HP=HP+d[x]*d[y]

for z in range(n):
    r+=d[z]*d[z]
    
print((HP-r)//2)

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n = int(input())
  D = list(map(int,input().split()))
  ans = 0
  for i in range(n):
    for j in range(i,n):
      if not i == j:
        ans += D[i] * D[j]
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
ns = list(map(int, input().split()))
result = 0
for i, j in combinations([k for k in range(n)], 2):
    result += ns[i] * ns[j]
print(result)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

kaihuku = 0

for i in range(n):
    for j in range(i,n):
        if i != j:
            kaihuku += d[i]*d[j]

print(kaihuku)

Submission status: Accepted

Solution code:
n=int(input())
takoyaki=list(map(int,input().split()))
ans=0
while len(takoyaki)>1:
    s=takoyaki.pop()
    for x in takoyaki:
        ans+=s*x
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

p = combinations(d, 2)

ans = 0
for v in p:
    ans += v[0]*v[1]

print(ans)

Submission status: Accepted

Solution code:
n, *d = map(int, open(0).read().split())

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

Submission status: Accepted

Solution code:
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(int(s/2))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

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

aaa = list(itertools.combinations(d,2))

ans = 0

for a in aaa:
    a1 = a[0]
    a2 = a[1]
    seki = a1*a2

    ans += seki

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
r=[]
for i in range(N):
    for k in range(i+1,N):
        r.append(d[i]*d[k])
print(sum(r))

Submission status: Accepted

Solution code:
N=int(input())

 
D=[]
 
D=list(map(int, input().split()))
sum=0

for i in range(N):
  for j in range(N):
    if i !=j:
      sum=sum+D[i]*D[j]
  
print (int(sum/2))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))

ans = 0
cnt = 0
for i in l:
    cnt += 1
    ll = l[cnt:]
    for j in ll:
        ans += i * j

print(ans)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    l=LIST()
    ct=0
    for i in range(n-1):
        for k in range(i+1,n):
            ct+=l[i]*l[k]
    print(ct)
if __name__ == '__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
lst = list(map(int, input().split()))
cure = []
for i in range(N):
    for j in range(i+1, N):
        cure.append(lst[i]*lst[j])
print(sum(cure))

Submission status: Accepted

Solution code:
n = int(input())
dlist = list(map(int,input().split()))

import itertools

kumiawaselist = list(range(0,n))
kumiawaselist = list(itertools.combinations(kumiawaselist,2))
ans = 0
for i in range(0,len(kumiawaselist)):
    ans += dlist[kumiawaselist[i][0]] * dlist[kumiawaselist[i][1]]

print(ans)

Submission status: Accepted

Solution code:
#abc143_b.py
N = int(input())
D = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i,N):
        if i!=j:
            ans += D[i]*D[j]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = np.array(lr())
recover = D[:, None] * D[None, :]
answer = recover.sum() - np.diag(recover).sum()
print(answer // 2)

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = np.array(lr())
recover = D[:, None] * D[None, :]
np.fill_diagonal(recover, 0)
answer = recover.sum() // 2
print(answer)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = int(input())
b = list(map(int,input().split()))

from itertools import combinations
print(sum(list(map(lambda x:x[0]*x[1],list(combinations(b,2))))))

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
D = iil()
sumD = sum(D)
ans = 0
for i in range(n):
    ans += D[i]*(sum(D)-D[i])
print(ans//2)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
D = iil()
ans = 0
for i in range(n):
    for j in range(i+1,n):
#        print(i,j)
        ans += D[i]*D[j] 
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
res = 0
sq = 0

for i in range(N):
    res += d[i]
    sq += d[i]**2
print((res**2-sq)//2)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
res = 0

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

print(res)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()
D2 = np.array(D)
E = D2[:, None] * D2[None, :]
E *= (np.ones((N, N), dtype=np.int32) - np.eye(N, dtype=np.int32))
answer = E.sum() // 2
print(answer)

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()
D2 = np.array(D)
answer = 0
for d in D:
    answer += (d * D2).sum() - (d ** 2)

print(answer // 2)

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))

ans = 0

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
a=sum(d)
b=0
for i in range(n):
  b+=d[i]*d[i]

print((a*a-b)//2)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import itertools

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

Submission status: Accepted

Solution code:
#takoyaki

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)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
souwa = 0
x = 1
s = []
for a in d:
    souwa += sum(a * d[x:])
    x += 1

print(souwa)

Submission status: Accepted

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

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