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:
n = int(input())
d_lst = list(map(int,input().split()))
good = 0

for i in range(n-1):
    good1 = d_lst[i]

    for j in range(n-1-i):
        good2 = d_lst[-1-j]
        good += good1 * good2

print(good)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(HP)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
SUM= 0
for i, d in enumerate(D):
    for d2 in D[i+1:]:
        SUM += d *d2
print(SUM)

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(n):
        if i == j: continue
        m = a[i] * a[j]
        ans += m
print(ans // 2)

Submission status: Accepted

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

sum = 0
for i in list(itertools.combinations(dList, 2)):
    sum += i[0] * i[1]
print(sum)

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

Submission status: Accepted

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

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:
from itertools import combinations
n = int((input()))
d = map(int, input().split())
print(sum([i[0] * i[1] for i in list(combinations(d, 2))]))

Submission status: Accepted

Solution code:
import itertools
N=int(input())
d=list(map(int,input().split()))
ans=0
for i in itertools.permutations(d,r=2):
    ans+=i[0]*i[1]
print(round(ans/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(i+1, n):
        ans += d[i]*d[j]

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

l = list(itertools.combinations(d, 2))
t = 0
for i, j in l:
    t += (i*j)
print(t)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    a = list(map(int, input().split()))
    total = 0
    for i in range(len(a)-1):
        for j in range(i+1, len(a)):
            total += a[i]*a[j]
    print(total)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

if __name__ == '__main__':
    n = int(input())
    d = list(map(int, input().split()))
    x = itertools.combinations(d, 2)
    ans = 0
    for i in x:
        ans += i[0] * i[1]
    print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())  # 文字列または整数(一変数)
    d = list(map(int, input().split()))  # 整数のリスト
    answer = 0

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

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n= int(input())
d= list(map(int,input().split()))
sum=0
k=0
while k<=n-1:
  sum+=int(d[k])
  k+=1
#ここまででたこ焼きの数とおいしさの総和を得る
main= sum-d[0]
piled=0
p=0
while p<=n-2:
  piled+= main*d[p]
  p+=1
  main-=d[p]
  

  
print(piled)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans_list = []
for i in range(0,N):
    for j in range(0,N):
        if i != j:
            ans_list.append(A[i]*A[j])
        
print(int(sum(ans_list)/2))

Submission status: Accepted

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

Submission status: Accepted

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

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

def main():
    *I, = map(int, open(0).read().split())
    N = I[0]
    d = I[1:]
    s= []

    for i in range(0, len(d)):
        for k in range(0, len(d)):
            if not i == k and i > k:
                s.append(d[i] * d[k])

    print(sum(s))


main()

Submission status: Accepted

Solution code:
a = int(input())
al = tuple(int(x) for x in input().split())
ll = len(al)
sm = 0
for x in range(ll):
    for y in range(x + 1, ll):
        sm += al[x] * al[y]
print(sm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))	
cnt = 0
for i in range(len(li)):
    for j in range(len(li)):
        cnt += li[i] * li[j] 
for k in range(len(li)):
    cnt -= li[k] ** 2
print(round(cnt/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools


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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ds=list(map(int,input().split()))
sum_=0
for i,d in enumerate(ds[:-1]):
    sum_+=sum([d*e for e in ds[i+1:]])
print(sum_)

Submission status: Accepted

Solution code:
import itertools
import operator


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

n = N * (N - 1) // 2
l = []
c = list(itertools.combinations(d, 2))
for i in range(n):
    l.append(operator.mul(c[i][0], c[i][1]))
ans = sum(l)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
x = 0
for i in range(0,n): #i+1なの注意
  for j in range(i+1,n):
    x += d[i] * d[j]
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os

def main():
	n = int(input())
	d_list = list(map(int, input().split()))
	score = 0
	for i in range(n-1):
		for j in range(i+1,n):
			if len(d_list) == i:
				continue
			score += d_list[i] * d_list[j]
	print(score)

if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
cnt = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        cnt += d[i] * d[j]
print(cnt//2)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
s = 0
i = 0
while i < n-1:
  k = i+1
  while k < n:
    s += li[i] * li[k]
    k += 1
  i += 1
print(s)

Submission status: Accepted

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

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

print(ans)

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


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#入力
N = int(input())
d = list(map(int,input().split()))
#美味しさの総和をsとする
s = 0
#相異なる2つの数の全ての掛け算の和を計算
for i in range(N-1):
  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()))
tot=sum(d)**2
for i in range(n):
  tot-=d[i]**2
print(tot//2)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
takoyaki=list(map(int,input().split()))
combs=list(itertools.combinations(takoyaki,2))
recovery=list(c[0]*c[1] for c in combs)
print(sum(recovery))

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(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(i+1,N):
    s += d[i]*d[j]

print(s)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
takoyaki = list(map(int, input().split()))
combs = list(itertools.combinations(takoyaki, 2))
recovery = list(c[0] * c[1] for c in combs)
print(sum(recovery))

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
ans = []
for i in range(n):
    for j in range(n):
        if i != j:
            ans.append(d[i] * d[j])
print(sum(ans) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result=0
for ind,item in enumerate(s[:-1]):
  for item2 in s[ind+1:]:
    result+=item*item2
    
print(result)

Submission status: Accepted

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

cnt = 0
for i, j in combinations(d, 2):
    cnt += i*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(n):
        if i  == j:
            pass
        else:
            ans += d[i] * d[j]
print(int(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:
N = int(input())
lis = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    for j in range(i+1,N+1):
        ans += lis[i-1]*lis[j-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
#--TAKOYAKII FESTIVAL 2019

N = int(input())
hp = [int(i) for i in input().split()]

pure = 0
for i in range(N):
  for j in range(N):
    if(i != j):
      pure = pure + hp[i] * hp[j]
    else:
      pass

print(int(pure/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(i+1,N):
        ans += d[i]*d[j]
print(ans)

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 = 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())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(n):
        if i != j:
            ans += l[i]*l[j]
print(ans//2)

Submission status: Accepted

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

print(sum(wa))

Submission status: Accepted

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

print(ans // 2)

Submission status: Accepted

Solution code:
import itertools

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

res = 0
for x, y in itertools.combinations(D, 2):
    res += x * y
print(res)

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

Submission status: Accepted

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

for i in range(0,len(A)):
    for j in range(i+1,len(A)):
        l.append(A[i]*A[j])

print(sum(l))

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):
	a,b=map(int,v)
	ans+=a*b
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

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

print(ans)
'''

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 itertools

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

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# ABC 143: B – TAKOYAKI FESTIVAL 2019
N = int(input())
d = [int(s) for s in input().split()]

recovery = 0

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

print(recovery)

Submission status: Accepted

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

happiness = 0
for i,tako in enumerate(list_aji):
  for j, tako in enumerate(list_aji):
    if i > j:
      happiness += list_aji[i] * list_aji[j]
print(happiness)

Submission status: Accepted

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

res = 0

for i in range(len(d)):
  index = 1
  while(i + index < N):
    res += d[i] * d[i + index]
    index += 1
print(res)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
d_list = [int(x) for x in input().split()]

ans = 0
for temp in combinations(d_list, 2):
    ans += temp[0] * temp[1]
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
aa = np.array(list(map(int, input().split())))
asum = sum(aa)
a2sum = sum(aa * aa)
print((asum*asum - a2sum)//2)

Submission status: Accepted

Solution code:
n = input()
line = input()
d_list = line.split(" ")
d_list = [int(d) for d in d_list]

ans = 0

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

Submission status: Accepted

Solution code:
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    D = input([int, N])
    dcomb = comb(D, 2)
    ans = 0
    for d in dcomb:
        ans += d[0] * d[1]
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int, input().split()))
s = 0
for i in range(len(li)):
  for j in range(len(li)):
    if i > j:
      s += li[i]*li[j]
print(s)

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
TS = []
cnt = 0

for i in range(N):
    for j in range(i+1,N):
        cnt = T[i] * T[j]
        TS.append(cnt)

print(sum(TS))

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

Submission status: Accepted

Solution code:
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

n=input1()
d=input_array()
result=0
for i in range(n):
	tako=d[i]
	for j in range(i+1,n):
		result+=d[i]*d[j]
print(result)

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:
n = int(input())
d = [int(x) for x in input().split()]

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

print(heal)

Submission status: Accepted

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

cnt =0
sum =0

for i  in d:
    cnt = cnt+1
    for  j in range(cnt+1,int(N)+1):
        sum = sum + i*d[j-1]
        
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    from itertools import permutations, combinations,combinations_with_replacement,product
    n=int(input())
    d=list(map(int,input().split()))
    dd=list(combinations(d,2))
    dsum=0
    for ddd in dd:
        dsum=dsum+ddd[0]*ddd[1]
    print(dsum)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    taco = [int(a) for a in input().split()]
    s = 0
    for i in range(N-1):
        for j in range(i+1, N):
            s += taco[i]*taco[j]
    print(s)
main()

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 itertools

N = int(input())
*D, = map(int, input().split())
combination = itertools.combinations(D, 2)

sum = 0
for x, y in combination:
    sum = sum + x*y
print(sum)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()
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,N):
        if i==j:
            continue
        ans += d[i]*d[j]

print(ans)

Submission status: Accepted

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

import itertools
import numpy

a = []
for pair in itertools.combinations(d, 2):
    a.append(numpy.prod(pair))

print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  D = list(map(int, readline().split()))
  ans = 0
  for i in range(N-1):
    for j in range(i+1,N):
      ans += D[i]*D[j]
  print(ans)
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N=int(input())
K=input().split()
list=[]
for i in range(0,N):
  list.append(int(K[i]))
ans=0
for i in range(0,N-1):
  for j in range(i+1,N):
    ans=ans+list[i]*list[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(n):
    if i!=j:
      sum+=d[i]*d[j]
      
print(str(sum//2))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#143_b

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

ans = 0
for i, di in enumerate(d):
    for j, dj in enumerate(d):
        if i == j:
            continue
        else:
            ans += di*dj
print(ans//2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, d: "List[int]"):
    sum = 0
    for i in range(N-1):
        for j in range(i,N):
            if i!=j:
                sum+=d[i]*d[j]

    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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