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 x in d:
    for y in d:
        ans += x * y
    ans -= x*x

print(ans//2)

Submission status: Accepted

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

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


ans = 0

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

print(str(ans))

Submission status: Accepted

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

a=A[0]
for i in range(1,N):
    b=A[i]
    recover+=a*b
    a=a+b
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(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()))
A=[]
for i in range(0,N-1):
  for r in range(i+1,N):
    A.append(d[i]*d[r])
print(sum(A))

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
A = list(map(int,input().split()))
res =list(itertools.combinations(A, 2))

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

print(ans)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
d = list(map(int,input().split()))
S = 0

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
##################################################################

if __name__ == "__main__":
    Input = [input() for i in range(2)]
    N = int(Input[0])
    d = list(map(int,Input[1].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()))

total = 0

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

Submission status: Accepted

Solution code:
takoyaki_count = input()

takoyaki = input().split(" ")

takoyaki_int = [int(n) for n in takoyaki]

life_up = []

x_count = 0
for x in takoyaki_int:
    y_count = 0
    for y in takoyaki_int:
        if x_count < y_count:
            life_up.append(takoyaki_int[x_count] * takoyaki_int[y_count])
            
        y_count += 1
    
    x_count += 1
    
print(sum(life_up))

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

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

    out = []
    for i in range(N):
        for j in range(i, N):
            if i != j:
                out.append(D[i] * D[j])
    print(sum(out))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, *d = map(int, open(0).read().split())
ans= 0
for i in range (len(d)):
  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()))
p = 0
for i in range(n):
    D = d[0]
    d.remove(D)
    p += D*sum(d)

print(p)

Submission status: Accepted

Solution code:
a = int(input())
b = map(int, input().split())
b = list(b)
t = []

r = [0]

def he(b, t, idx, tm):
    if len(t) == 2:
        tm[0] += t[0] * t[1]
        return
    for i in range(idx, len(b)):
        t.append(b[i])
        he(b, t, i + 1, tm)
        t.pop()

he(b, t, 0, r)

print(r[0])

Submission status: Accepted

Solution code:
N = map(int, input())
d_list = list(map(int, input().split()))
#3
#3 1 2ときたらsum = 3*1,3*2,1*2 で、 1*3と2*1は不要
#i * i+1, i * i+2, ..., i+1 * i+2, i+1 * i+2, ..., i*3 * i*4,...と行った形で計算してsumを求める。

i_max = len(d_list) #d_list = [0, 1, 2]なら3
sum = 0

for i in range(i_max):
    j = i
    while j + 1 <  i_max:
        mul = d_list[i] * d_list[j + 1]
        sum += mul
        j += 1

print(sum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
D = [int(i) for i in input().split()]

total = 0
for i in range(N):
    for j in range(N):
        if i>=j:
            continue
        total += D[i]*D[j]

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
d = [0 for _ in range(N)]
d = list(map(int, input().split()))

import itertools

ans  = sum([p[0]*p[1] for p in list(itertools.combinations(d,2))])

print(ans)

Submission status: Accepted

Solution code:
a = input()
b = input()
bs = [int(i) for i in b.split()]
print((int)((sum(i*j for i in bs for j in bs)-sum(i*i for i in bs))/2))

Submission status: Accepted

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

recover = 0

for n in range(0,N):
    for m in range(n+1,N):
        recover += d[n] * d[m]

print(recover)

Submission status: Accepted

Solution code:
N = int(raw_input())
num = list(map(int, raw_input().split()))

res = 0

for i in range(N):
    for j in range(i, N):
        if i == j:
            continue
        res += num[i] * num[j]

print(res)

Submission status: Accepted

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




print(power)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
b= list(map(int, input().split()))  # 114514 810 893
c=[]
for i in b:
  c.append(i**2)

num=(sum(b)**2-sum(c))//2
print(num)

Submission status: Accepted

Solution code:
total_tako = int(input())
tako_values = list(map(int, input().split()))
sum_value = 0

for i in range(total_tako):
  for j in range(total_tako):
    if j != i:
      sum_value += tako_values[i] * tako_values[j]

print(int(sum_value / 2))

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
D=np.array(list(map(int,input().split())))
# (i,j)要素がi,jを食べたときの回復量(i*j)
kachi_matrix= np.expand_dims(D,axis=0) * np.expand_dims(D,axis=1)
np.fill_diagonal(kachi_matrix,0.0)
print(np.sum(kachi_matrix)//2)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys

n = int(sys.stdin.readline().strip())
d = [ int(x) for x in sys.stdin.readline().strip().split() ]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
N = int(input())
d = list(map(int, input().split()))
ans = 0
while len(d) > 1:
    current = d[0]
    for y in range(len(d)):
        ans += current * d[y]
#         print(ans)
    ans -= current ** 2
    d.pop(0)
print(ans)

Submission status: Accepted

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

total=0
for i in range(len(D)):
    for j in range(i+1,len(D)):
        #print(str(i)+" "+str(j))
        total+=D[i]*D[j]

print(total)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    d = map(int, input().split())
    ans = 0
    for x, y in combinations(d, 2):
        ans += x * y

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
s=0
a = list(map(int,input().split()))
for i in combinations(a,2):
    for j in range(len(i)-1):
        s += i[0]*i[1]
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
dmat = input().split()
dmatint = []
for i in range(len(dmat)):
    dmatint.append(int(dmat[i]))

#print(N)
#print(dmatint)

#全パターン選ぶ
allpatern = list(itertools.combinations(range(N), 2))
#print(allpatern)
sum = 0
for patern in allpatern:
    first = patern[0]
    second = patern[1]
    #print(first)
    #print(second)
    product = dmatint[first]*dmatint[second]
    sum += product
print(sum)

Submission status: Accepted

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

n = int(input())
l = [int(s) for s in input().split()]
ans = 0
for v in itertools.combinations(l, 2):
    ans += v[0]*v[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(i+1,n):
        ans+=d[i]*d[j]

print(ans)

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:

import itertools
 
N = int(input())

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

ans = 0

for i in itertools.combinations(li, r=2):
    ans += i[0] * i[1]
    
print(ans)

Submission status: Accepted

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

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

B = int(input())
D = list(map(int,input().split()))
ans_list = list(itertools.combinations(D, 2))
ans = 0
for i,j in ans_list:
    ans += (i * j)
print(ans)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
def calc(N, d):
    r = 0
    for i in range(N):
        for j in range(i + 1, N):
            r += d[i] * d[j]

    return r


N = int(input())
d = [int(s) for s in input().split()]
print(calc(N, d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
takoyakis = list(map(int, input().split()))
sum = 0
for i, takoyaki in enumerate(takoyakis):
    for t in takoyakis[i + 1:]:
        sum += takoyaki * t
print(sum)

Submission status: Accepted

Solution code:
n = input().split(" ")
i = input().split(" ")
i = [int(k) for k in i]

r = (sum(i) * sum(i) - sum([j * j for j in i])) / 2
r = int(r)

print(r)

Submission status: Accepted

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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = [int(e) for e in lines[0].split(" ")][0]
    d = [int(e) for e in lines[1].split(" ")]

    return (n, d)


def solve(n, d):

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

    return s


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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


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

sum_list = 0
for i in range(len(list)):
    sum_list += list[i][0] * list[i][1]

print(sum_list)

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())
d=list(map(int,input().split()))
ans = 0
for i,x in enumerate(d):
    for y in d[i+1:]:
        ans+=x*y
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, d: "List[int]"):
    total = 0
    for v in itertools.combinations(d, 2):
        total += v[0] * v[1]
    print(total)
    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=input()
D=D.split()
D=[int(item) for item in D]
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())
d = list(map(int, input().split()))

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sum = 0
for i in range(N):
  for m in range(i+1, N):
    xy = d_list[i]*d_list[m]
    sum += xy

print(sum)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
i=0
j=0
p=0
while(i<len(a)):
  j=i+1
  s=0
  while(j<len(a)):
      s=s+a[j]
      j=j+1
  
  p=p+s*a[i]
  i=i+1
print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 and 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 j in range(N):
    if i==j:
      continue
    ans+=d[i]*d[j]/2
print(int(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(N-i-1):
        sum += A[i] * A[i+1+j]
        
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i in input().split()] 
C = 0
for i in range(N):
	for j in range(N):
		if i<j:
			C+=D[i]*D[j]

print(C)

Submission status: Accepted

Solution code:
import itertools

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

result = 0
comb = itertools.combinations(d_list, 2)
for pattern in comb:
    result += pattern[0] * pattern[1]

print(result)

Submission status: Accepted

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

_n = int(input())
dlist = [item for item in map(int, input().split())]

sd = 0
while len(dlist) > 1:
    sd += dlist[0] * sum(dlist[1:])
    dlist = dlist[1:]


print(sd)

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

Submission status: Accepted

Solution code:
import itertools
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
N = int(readline())
ds = list(map(int,readline().split()))

ans = 0
for v in itertools.combinations(ds, 2):
    #print(v)
    ans += v[0] * v[1]
    
print(ans)

Submission status: Accepted

Solution code:
def A():
    temp = [int(i) for i in input().split()]
    print(max(0, temp[0]-2*temp[1]))

def B():
    N = int(input())
    T = [int(i) for i in input().split()]
    s = 0
    for i in range(N):
        for j in range(i):
            s += T[i]*T[j]
    print(s)

B()

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

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

for i in combination:
    taste_sum += i[0] * i[1]

print(taste_sum)

Submission status: Accepted

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

s = sum(L)
p = 0
for a in L:
 p += a*a

ans=(s*s-p)/2

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list = input().split()
d = [int(n) for n in list]
sum = 0
sum_minus = 0
for i in range(N):
  sum_minus += d[i]*d[i]
  for k in range(N):
    sum += d[i]*d[k]
print(int((sum - sum_minus)/2))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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


print(re)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))

N = int(input())
D = inpl()
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=input().split()
di = [int(s) for s in d]
a=0
for i in range(0,n):
  for j in range(i+1,n):
    a+=di[i]*di[j]
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = 0
l = len(d)
for i in range(l-1):
    if d[i] == 0:
        continue
    else:
        for j in range(i+1, l):
            p += d[i] * d[j]
print(p)

Submission status: Accepted

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

s = 0
while len(D) > 0:
  d = D.pop(0)
  s += d * sum(D)
  
print(s)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def main():

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


if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import itertools

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


def solve():
    point = 0

    for pattern in list(itertools.combinations(D, 2)):
        point += pattern[0] * pattern[1]

    return point


print(solve())

Submission status: Accepted

Solution code:
N = int(input())
d = [i for i in 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()))
answer = 0
for i in range(len(D)):
    for j in range(i, len(D)):
        if i != j:
            answer += D[i]*D[j]
print(answer)

Submission status: Accepted

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

	print(sum)

main()

Submission status: Accepted

Solution code:
import itertools

takoyaki_num = int(input())
takoyaki_hp = input().split()

takoyaki_combi = itertools.combinations(takoyaki_hp , 2)
heal_hp = 0
for takoyakis in list(takoyaki_combi):
    heal_hp_of = 1
    for takoyaki in takoyakis:
        heal_hp_of *= int(takoyaki)
    heal_hp += heal_hp_of
print(heal_hp)

Submission status: Accepted

Solution code:
N=int(input())
d=[int(n) for n in input().split()]
memo=[]
ans=0
for i in range(N):
    for j in range(N):
        if (i,j) in memo or (j,i) in memo or i==j:
            pass
        else:
            ans += d[i]*d[j]
            memo.append((i,j))
print(ans)

Submission status: Accepted

Solution code:

import itertools

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

xx = itertools.combinations(D, 2)
out = 0
for x in xx:
    out += x[0] * x[1]
print(out)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import numpy as np

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

for v in itertools.combinations(d_list, 2):
  ans += np.prod(v)
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
N = input()
D = [int(x) for x in input().split()]
ans = 0
for x, y in combinations(D, 2):
    ans += x*y
print(ans)

Submission status: Accepted

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

c=0

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

Submission status: Accepted

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

Submission status: Accepted

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

while N > 1:
    for i in range(N - 1):
        point = d[0] * d[i + 1]
        count = count + point
    N = N - 1
    del d[0]

print(count)

Submission status: Accepted

Solution code:
n = int(input())

d = [int(x) for x in input().split()]
r = 0
for i in range(n):
    r += d[i]*d[i]

ans = (sum(d)*sum(d) - r)//2
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
D = [int(_) for _ in input().split()]
ans = 0
for i, j in itertools.combinations(range(N), 2):
    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):
    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-1):
    for n in range(len(D)-1):
        ans += D[0]*D[n+1]
    del D[0]
print(ans)

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
N = int(input())
d = inpl()
S = sum(d)
T = sum(x**2 for x in d)
print((S**2-T)//2)