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 = 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 = list(map(int,input().split(' ')))
ans = 0
for i in range(len(D)):
    for i1 in range(i,len(D)):
        if i== i1:
            continue
        ans = ans + (D[i] * D[i1])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
oishisa_list = input().split(" ")

N = int(N)

goukei = 0

for i in oishisa_list:
  for j in oishisa_list:
    goukei += int(i) * int(j)

issyo = 0
for i in oishisa_list:
  issyo += int(i) ** 2

print((goukei - issyo) // 2)

Submission status: Accepted

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

result = 0
for i in range(n - 1):
    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(' ')))

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

print(health)

Submission status: Accepted

Solution code:
A = int(input())
d = list(map(int, input().split()))
Y = 1
sum = 0

for x in range(A):
    for y in range(Y, A):
        sum += d[x]*d[y]
    Y += 1

print(sum)

Submission status: Accepted

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

for i in itertools.permutations(d, 2):
    S += i[0] * i[1]
print(int(S / 2))

Submission status: Accepted

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

print(k)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
D = [int(x) for x in input().split()]

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

Submission status: Accepted

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

S = sum(D)
W = [(S-d) * d for d in D]
print(sum(W) // 2)

Submission status: Accepted

Solution code:
n = int(input())
lis = [int(i) for i in input().split()]
#print(lis)
way = 0

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

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

print(sum)

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())
ans = 0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        ans += a[i] * a[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())
L = list(map(int, input().split()))
out = 0
for i in range(n):
  for j in range(i+1, n):
    out += L[i] * L[j]

print(out)

Submission status: Accepted

Solution code:
x = input()
T = map(int, raw_input().split())

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

print ans

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
d = list(map(int, input().split()))
d = np.array(d).reshape((1,-1))
M = (np.ones((N,N))-np.eye(N))/2
print(np.dot(np.dot(d,M), d.T)[0,0].astype(np.int))

Submission status: Accepted

Solution code:
inputbox1 = input()
inputbox2= input()
N = int(inputbox1)
box = inputbox2.split()

d = [int(s) for s in box]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

print(sum)

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:
import itertools
import numpy as np

N = int(input())
lst = np.array(list(map(int,input().split())))
lst2 = np.array(list(itertools.combinations(lst,2)))
lst3 =[]

for i in range(len(lst2)):
               dot = np.dot(lst2[i][0],lst2[i][1])
               lst3.append(dot)

print(sum(lst3))

Submission status: Accepted

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

Submission status: Accepted

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

    for xi in range(len(d)):
        for yi in range(xi+1, len(d)):
            if xi != yi:
                ans += d[xi] * d[yi]

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    for xi in range(len(d)):
        for yi in range(len(d)):
            if xi != yi:
                ans += d[xi] * d[yi]

    print(ans // 2)


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

print(ans)

Submission status: Accepted

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

print(sum(l[i]*sum(l[i+1:]) for i in range(len(l)-1)))

Submission status: Accepted

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

print(sum(l[i]*x for i in range(len(l)-1) for x in l[i+1:]))

Submission status: Accepted

Solution code:
n = int(input())
ar = [int(x) for x in input().split()]

sm = 0
for i in range(0, n):
  for j in range(i+1, n):
    sm = sm + ar[i]*ar[j]
print(str(sm))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
li = list(map(int, input().split()))
a = 0
for i in range(N):
  for j in range(N):
    if i > j:
      a += li[i]*li[j]
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(i,j,sum)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
d_list = list(map(int,input().split()))
d_com = list(itertools.combinations(d_list,2))
res = 0
for a,b in d_com:
    res += a*b
print(res)

Submission status: Accepted

Solution code:
### B - Curtain ###
N = int(input())
D = list(map(int, input().split()))

from itertools import combinations

cb = list(combinations(D, 2))
my_lambda = lambda x: x[0] * x[1]
rslt = sum(list(map(my_lambda, cb)))

print(rslt)

Submission status: Accepted

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

for A in range(N-1):
  for B in range(A+1,N):
    TotalList += D[A]*D[B]
    

print(TotalList)

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

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    sc = Scan()
    a = sc.intarr()[0]
    d = sc.intarr()

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

    print(sum)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

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):
    cnt += D[i]*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())
ds = map(int, input().split())
ds = list(ds)

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

print(acc)

Submission status: Accepted

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

hp=0
for i in range(tako-1):
  for j in range(i+1,tako):
    hp=takolist[i]*takolist[j]+hp

print(hp)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
deliciouses = [int(i) for i in input().split()]
recovery_amounts = []
for i in itertools.combinations(deliciouses, 2):
    recovery_amounts.append(i[0] * i[1])
print(sum(recovery_amounts))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

total = sum(d)
print(sum([(total-i) * i for i in d]) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

heal = 0

for i in range(N):
    for j in range(i+1 , N):
        heal += deliciaus[i] * deliciaus[j]
    
print(heal)

Submission status: Accepted

Solution code:
import itertools

n = input()
li = map(int, input().split())
lii = itertools.combinations(li,2)
sum = 0
for _ in lii:
    sum += _[0]*_[1]


print(sum)

Submission status: Accepted

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

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

sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

sum = 0
res = []
for idx, t in enumerate(takoyaki):
  for i in range(idx + 1, n):
    sum += t * takoyaki[i]

print(sum)

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

Submission status: Accepted

Solution code:
# B
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 = list(map(int, input().split()))
 
score = 0
for i,j in combinations(range(N), 2):
  score += d[i] * d[j]
print(score)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
D=list(map(int,input().split(' ')))
sum_=0
for cmb in itertools.combinations(D, 2):
  sum_+=cmb[0]*cmb[1]

print(sum_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i, ni in enumerate(d):
    for j, nj in enumerate(d):
        if j <= i:
            continue
        else:
            ans += ni * nj

print(ans)

Submission status: Accepted

Solution code:
li = list(map(int,input().split()))
n=li[0]
d = list(map(int,input().split()))
sum=0

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

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
num=int(input())
data=input().split()
sum=0
 
for a in range(num):
  for b in range(num-1-a):
    sum+=int(data[a])*int(data[-1-b])
print(sum)

Submission status: Accepted

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

S = 0

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

print(S)

Submission status: Accepted

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

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 = 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:
import numpy
N = int(input())
b = list(int(i) for i in input().split())
sum = 0
for i,x in enumerate(b):
    for y in range(i+1,N,1):
        sum =sum +x*b[y]
print(sum)

Submission status: Accepted

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

for i in di:
    ans1 += i * i
    for j in di:
        ans0 += i * j
ans = int((ans0 - ans1)/2)

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
from functools import reduce
from operator import add

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

print(reduce(add, map(lambda x: x[0] * x[1], combinations(d, 2))))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
list_A=[]
list_B=[]
for num3 in d:
    list_B.append(int(num3*num3))
k=sum(list_B)
for num in d:
    for num2 in d:
        list_A.append(int(num*num2))
print((sum(list_A)-k)//2)

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
for x in range(n):
    for y in range(x+1,n):
        result += d[x]*d[y]

print(result)

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
import itertools as it
import numpy as np
al=list(it.combinations(a,2))
total=0
for i in al:
    total+=np.prod(i)
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = 0

for i in range(n):
    for j in range(n):
        if i > j:
            s += ls_d[i] * ls_d[j]

print(s)

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

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
d = LI()
takoyakis = sum(d)
ans = 0
for takoyaki in d:
    ans += (takoyakis - takoyaki) * takoyaki
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 s in range(i+1, N):
        sum += d[i] * d[s]
print(sum)

Submission status: Accepted

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

sum = 0

for i in range(1, N):
    for s in range(N-1):
        if (s + i) < N:
            sum = sum + (d[s] * d[s+i])
        else:
            break

print(sum)

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

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

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

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 = input()
d = list(map(int, input().split()))
c = list(itertools.combinations(d,2))
sum = 0
for i,j in c:
  sum += i*j
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
d_s = list(map(int, input().split()))
S = sum(d_s)
print(sum(list(map(lambda x:(S-x)*x, d_s)))//2)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
b = list(map(int, input().split()))
c = list(itertools.combinations(b,2))
a = 0
for i,j in c:
    a += i*j
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

power_sum = 0
d_comb = itertools.combinations(d_list, 2)
for i in d_comb:
  power_sum+=i[0]*i[1]
  
print(power_sum)

Submission status: Accepted

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

for i in range(n-1):
  a = sum(d[i+1:n])
  s += d[i]*a
  
print(s)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import itertools
print(sum([i * j for i, j in itertools.combinations([int(i) for i in (input(),input())[1].split()], 2)]))

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
d = np.array([int(i) for i in input().split(" ")])
print(np.sum(np.tril(d * d.reshape((len(d), -1)), k=-1)))

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

health = 0
combination = list(itertools.combinations(d, 2))

for x, y in combination:
    health += x * y

print(health)

Submission status: Accepted

Solution code:
# coding: utf-8

a = int(input())
blist = list(map(int, input().split()))

ans = 0

for i in range(0, a):
  if (i == a):
  	break
  
  for j in range(i + 1, a):
    ans += blist[i] * blist[j]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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 = s + d[i]*d[j]
       
s = s / 2

print(int(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input().strip()
d = input().split()
n = int(n)
ans = 0

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

Submission status: Accepted

Solution code:
import itertools

if __name__ == '__main__':

	n = int(input())

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

	B =list(itertools.combinations(A,2))

	cnt = 0
	for lst in B:
		cnt += lst[0] * lst[1]

	print(cnt)

Submission status: Accepted

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

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

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

ans = 0
for a, b in combinations(D, 2):
    ans += a * b
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

N=int(input())
d=list(map(int,input().split()))
x=[d[i]**2 for i in range(N)]
m=sum(d)**2-sum(x)
print(m//2)

Submission status: Accepted

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

print(res)

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = sum([x*y for x, y in list(combinations(A, 2))])
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(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_d=0
sum_d2=0
ans=0

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

print(int(ans/2))

Submission status: Accepted

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

for i in range(n):
    sum_d+=d[i]
    sum_d2+=d[i]**2

ans=(sum_d**2-sum_d2)/2
print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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)