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 sys
#import bisect
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

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

D = deque(D)
sum0 = D.pop()
hp = 0

for _ in range(N-1):
    d = D.pop()
    hp += d * sum0
    sum0 += d

print(hp)

Submission status: Accepted

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

print(sum([i[0] * i[1] for i in list(itertools.combinations(d, 2))]))

Submission status: Accepted

Solution code:
from itertools import combinations

num = int(input())
num_list = list(map(int,input().split()))
matrix = list(combinations(num_list,2))

sum = 0

for i in range(0,len(matrix)):
  sum = sum + matrix[i][0]*matrix[i][1]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  Ds = list(map(int, input().strip().split()))
  ans = 0
  for i in range(n):
    for j in range(i+1, n):
      ans += Ds[i] * Ds[j]
  print(ans)
  
  
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

sq_summation = 0
summation = 0

for e in l:
    sq_summation += e**2
    summation += e

print(int((summation ** 2 - sq_summation) / 2))

Submission status: Accepted

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

s = 0
for i, x in enumerate(v[:n-1]):
  for j, y in enumerate(v[i+1:]):
    s += y*x
    
print(s)

Submission status: Accepted

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

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
# Your code here!
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]
        else:
            continue
print(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):
    ans += D[i]*D[j]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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


count = 0

for i in range(N): #0,1,2
  for j in range(i):#1,0  2,0, 2,1
    B = d[i] * d[j]
    count = count + B
    
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
takoyaki_list = list(map(int,input().split()))
total = 0 
listA = []
for i in range(N):
    for j in range(N-1):
        if i == j:
            pass
        else:
            A = [i,j]
            A.sort()
            listA.append(A)
listA = list(map(list, set(map(tuple, listA))))
for i,j in listA:
    A,B = [takoyaki_list[i],takoyaki_list[j]]
    total += A * B
print(total)

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
S = 0
# print("N=",N)
# print("D=",D)

for i in range(N):
    for j in range(i, N-1):
        S = S + D[i] * D[j+1]
#        print("i=",i,"j=",j, "D=",D[i],D[j+1], "S=",S)
print(S)

Submission status: Accepted

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

s = sum(x*y for x,y in product(a,a))
t = sum(x*x for x in a)

print((s - t)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
dlist = list(map(int, input().split()))
A = sum(dlist) ** 2 // 2
B = sum([i ** 2 for i in dlist]) // 2

print(A - B)

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()))
h = len(d)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

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()))
sq = list(d[i]**2 for i in range(n))
ans = -sum(sq)
for i in range(n):
    for j in range(n):
        ans += d[i] * d[j]
print(int(ans/2))

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

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

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=list(map(int,input().split()))
print(sum(d[x]*d[y] for x in range(N) for y in range(x,N) if x!=y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

r = sum([x * y for x, y in combinations(D, 2)])
print(r)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

#num = (1 / 2) * N * (N - 1)

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

SUM_D = sum(D)
xy = 0
xx = 0
for d in D:
    xy += d * SUM_D
    xx += d * d

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

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
d=list(map(int,input().split()))
total=0
nlis=[i for i in range(1,N+1)]
com=list(itertools.combinations(nlis,2))


for j in range(len(com)):
  total+=d[com[j][0]-1]*d[com[j][1]-1]
print(total)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

l = list(itertools.combinations(D, 2))
sum = 0
for nums in l:
    sum += nums[0]*nums[1]

print(sum)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
tako = list(map(int, input().split()))
comb = list(itertools.combinations(tako, 2))
ans = 0
for i in comb:
    ans += i[0] * i[1]

print(ans)

Submission status: Accepted

Solution code:
#python3
from itertools import combinations
def main():
    n = int(input())
    d = [int(i) for i in input().split()]
    sum = 0 
    for i in combinations(d, 2):
        sum += i[0]*i[1]
    print(sum)
main()

Submission status: Accepted

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

heal = list(combinations(range(n), 2))

sums = 0
for i in heal:
    sums += d[i[0]] * d[i[1]]

print(sums)

Submission status: Accepted

Solution code:
import itertools

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

comb = itertools.combinations(d, 2)

comb = [item[0]*item[1] for item in comb]

print(sum(comb))

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

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

print(s)

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(int(Sum/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] * d[i]

Sum = int(Sum/2)
print(Sum)

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(N):
        if i!=j:
            total+=d[i]*d[j]
print(total//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc143/tasks/abc143_b

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

Submission status: Accepted

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

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

print(R)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

#print(N)
#print(mylist)

answer=0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

all = list(itertools.permutations(d,2))

ans = 0
for i in range(len(all)):
    ans += all[i][0]*all[i][1]

print(int(ans/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-

import itertools


def main():
    N = int(input())
    D = list(map(int, input().split()))
    result = 0
    comb = list(itertools.combinations(D, 2))
    for a, b in comb:
        result += a * b
    print(result)


if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
tako_list=list(map(int,input().split()))
sum=0
for v in itertools.combinations(tako_list,2):
    sum+=v[0]*v[1]
print(sum)

Submission status: Accepted

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

import itertools

C = list(itertools.combinations(D,2))

ans =0
for c in C:
  ans += c[0]*c[1]
  
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
S=sum(d)
S_2=S**2
d_2 = [i**2 for i in d]
S_3=sum(d_2)
print(int((S_2-S_3)/2))

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

recover = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        recover += d[i] * d[j]
print(recover)

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:
from itertools import permutations,combinations

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

ans = 0

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

Submission status: Accepted

Solution code:
def main(n,d):
    sumVal = 0
    for i in range(n-1):
        for j in range(i+1, n):
            sumVal += d[i]*d[j]
    return sumVal

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
arrd = list(map(int,input().split()))
import itertools 
num = 0
for i in itertools.permutations(arrd,2):
    num += i[0] * i[1]
print(num//2)

Submission status: Accepted

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

for i,j in itertools.combinations(l,2):
  sum += i*j

print(sum)

Submission status: Accepted

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

ans = 0
for i, d1 in enumerate(D):
    for d2 in D[i+1:]:
        ans += d1 * d2
print(ans)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

ans=0

for i in range(n):
    for j in range(n):
        if j <i:
            ans+=dl[i]*dl[j]
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	d = LI()

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


main()

Submission status: Accepted

Solution code:
import itertools


def x(L):
    return L[0] * L[1]


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

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

ans = 0
for i in l:
    ans += x(i)

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

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

ans = 0
for i in range(len(l)):
    ans += l[i][0] * l[i][1]

print(ans)

Submission status: Accepted

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

for i in range(n):
    for j in range(i+1,n):
        ans.append(d[i]*d[j])
print(sum(ans))
#print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

l = []

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

print(num)

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
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()

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

print(su)

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
for i in range(n-1):
  for j in range(i+1, n):
    result += list[i] * list[j]

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
*d,=map(int,input().split())
ans=[]
for i in range(1,n):
    for j in range(i):
        ans.append(d[i]*d[j])
print(sum(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):
    #print(i,j)
    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 ii in range(i + 1, N):
        ans += D[i] * D[ii]

print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

score = 0
for i in range(0, n-1):
    for j in range(i+1, n):
        score += d_list[i] * d_list[j]

print(score)

Submission status: Accepted

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

Submission status: Accepted

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



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

Submission status: Accepted

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

sum=0

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

print(sum)

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

for dd in range(len(d)):
  for e in range(len(d)):
    if dd < e:
      ans+=d[dd]*d[e]
      
print(ans)

Submission status: Accepted

Solution code:

import sys
import itertools
row = sys.stdin.readline
def read_int(row):
    return int(row().rstrip())
def read_ints(row):
    return list(map(int, row().split()))
  
N = read_int(row)
d_ls = read_ints(row)
print(sum([i[0] * i[1] for i in list(itertools.combinations(d_ls,2))]))

Submission status: Accepted

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

print(total)

Submission status: Accepted

Solution code:
N = int(input())
d = input().split()
d = [int(i) for i in d]
l = []
for i in range(N):
  for j in range(i+1,N):
    p = d[i] * d[j]
    if i == j:
      p = 0
    l.append(p)
print(sum(l))

Submission status: Accepted

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

ans=0
s=sum(l)

for i in range(n):

    ans+=l[i]*(s-l[i])

print(int(ans/2))

Submission status: Accepted

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

print(a)

Submission status: Accepted

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

Submission status: Accepted

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