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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

double_ans = 0
ans = 0

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

print(int(double_ans / 2))

Submission status: Accepted

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

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

print(sum_num)

Submission status: Accepted

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

l = len(arr)

sumi = 0

for i in range(l):
  for j in range(i+1,l):
    sumi += arr[i]*arr[j]
    
print(sumi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = [int(item) for item in input().split(' ')]
sum_ = 0
for i in range(len(d)):
    for j in d[i+1:]:
        sum_ += d[i] * j
print(sum_)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

sum = 0
power = list(itertools.combinations(d_list,2))
for p in power:
    sum = sum + p[0] * p[1]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
import numpy as np
d_vec = np.array( list(map(int, input().split()) ))

d_mat = np.outer(d_vec, d_vec)
print(np.sum(np.triu(d_mat, k=1)))

Submission status: Accepted

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

sum = 0
import itertools
for x,y in itertools.combinations(d, r=2):
  sum += x * y

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

map_o = map(int, input().split())
Dn = list(map_o)

tairyoku = 0

j = 0
while j < N-1:
	base = Dn[j]

	k = j+1
	while k < N:
		tmp = base*Dn[k]
		tairyoku += tmp
		k += 1
	j += 1

print(tairyoku)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
l2 = sum([i**2 for i in l])

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

print((ans - l2)//2)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int, input().split()))
a=(sum(d))**2

def square(list):
    return [i ** 2 for i in list]

b=sum(square(d))
result=(a-b)/2
print(int(result))

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

Submission status: Accepted

Solution code:
N = int(input())
d = input().split()
S = 0

for i in range(len(d)):
    d[i] = int(d[i])

for i in range(len(d)):

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

print(S)

Submission status: Accepted

Solution code:
import numpy as np

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

n = int()
all_sum = int(0)

def calcsum(b,b2):
  sum = int(0)
  for value in b2:
    sum += b * value 
  return sum

for index,value in enumerate(a):
  all_sum += calcsum(value,a[index+1:])
  
print(all_sum)

Submission status: Accepted

Solution code:
import numpy as np

takoyaki_num = int(input())
oishisa_list = input().split(" ")

oishisa_vec = np.array(oishisa_list, dtype=int)

# 計算
oishisa_outer_sum = np.sum(np.outer(oishisa_vec, oishisa_vec))
oishisa_dot = np.dot(oishisa_vec, oishisa_vec)

total_heal_int = int((oishisa_outer_sum - oishisa_dot) / 2)
print(total_heal_int)

Submission status: Accepted

Solution code:
import itertools

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

def calc(x,y):
  return x * y

#def range_calc():
  
sum = 0
for i in itertools.combinations(list_, r=2):
    sum += calc(*i)
  
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 d[i+1:]:
        ans += d[i] * j

print(ans)

Submission status: Accepted

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

done_dict = {}
sum = 0
for i in range(input1):
    for j in range(input1):
        if i != j and (not done_dict.get(j)):
            sum += input_list[i] * input_list[j]
#            print("i:", i, "j:", j, " ", input_list[i] * input_list[j])
    done_dict[i] = True
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

s = int(0)

for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        else:
            s += d[i] * d[j]

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

count = int(input())
balls = list(map(int, input().split()))
mutable_balls = copy.deepcopy(balls)

ans = 0
for i, ball in enumerate(balls):
  for j, ball2 in enumerate(balls):
    if i != j:
      ans += ball * ball2

print(int(ans / 2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
# スペース区切りの整数の入力
d = [int(a) for a in input().split()]
sum = 0
i, j = 0, 0
while i < N:
  j = i+1
  while j < N:
    sum += d[i] * d[j]
    j += 1
  i+= 1
print('{}'.format(sum))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = input()
b = [int(i) for i in input().split()]
cnt = 0
for c in itertools.combinations(b, 2):
    cnt = cnt + c[0]*c[1]
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

s = 0

for i in xrange(N):
	for	j in xrange(i+1,N):
		s += li[i]*li[j]

print s

Submission status: Accepted

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

count = 0
ans = 0

for i in d_list:
    count += 1
    sum_temp = 0
    for m in range(count, n):
        sum_temp += i*d_list[m]
    ans += sum_temp

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

result = 0
for i in itertools.combinations((data), r=2):
  result += i[0] * i[1]

print(result)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
A = list(map(int, input().split()))
s = []
ans = 0
for i in itertools.combinations(A, r=2):
    s.append(i)

for x in s:
    ans += x[0]*x[1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int, input().split(' ')))
sum = 0

for i in range(N):
    for j in range(N-1):
        if i < (j+1):
            sum = sum + nums[i]*nums[j+1]

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

Submission status: Accepted

Solution code:
import sys

total = 0
input = sys.stdin.readline

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

for i in range(N):
  sub_total = 0
  M = point_list.pop()
  for p in point_list:
    sub_total += M * p
  total += sub_total

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
array = list(map(int, input().strip().split()))
sum_value=0
number_value=0
for item in array:
  sum_value = sum_value + item * number_value
  number_value = number_value + item
print(sum_value)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
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("{}".format(sum))

Submission status: Accepted

Solution code:
import sys

N = int(input())
a = list(map(int,input().split()))
b = len(a)

wa = 0
for i in range(b-1):
    for j in range(i+1,b):
        wa += a[i]*a[j]


print(wa)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1行目の入力を数値として扱う
n = int(input())
# 2行目の入力を数値のリストとして扱う
d = list(map(int, input().split()))
     
# 文字列の長さ分の配列を用意
ans = 0
     
# 
for i in range(0, n - 1):
    for j in range(0, n):
        if j <= i:
            continue
#        print(str(i) + "," + str(j))
        ans += d[i] * d[j]

# 答えの出力
print(ans)

Submission status: Accepted

Solution code:
import itertools

num = input()
recoveryValues = input().split()
recoveryTotal = 0

combinations = itertools.combinations(recoveryValues, 2)

for v in combinations:
    recoveryTotal += (int(v[0]) * int(v[1]))

print(recoveryTotal)

Submission status: Accepted

Solution code:
import numpy as np
n=input()
data=np.array(list(map(int,input().split(' '))))
z=0
for i in range(len(data)-1):
    for j in range(i+1,len(data)):
        z+=data[i]*data[j]
print(z)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split())) 
s=0
# print(d)
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()))

s = 0

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

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

Submission status: Accepted

Solution code:
def square(list):
    return [i ** 2 for i in list]

n=int(input())
dlist=list(map(int, input().split()))
ans=0
s= sum(dlist)
w= sum(square(dlist))
ans=(s**2-w)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0
for i, d1 in enumerate(d):
    for j, d2 in enumerate(d[i+1:]):
        cnt += d1 * d2
print(cnt)

Submission status: Accepted

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

import itertools
s = sum([i * j for i, j in list(itertools.combinations(d, 2))])
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N= int(input())


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


from itertools import combinations

c = combinations(d, 2)
ans = 0
for i, j in c:
    ans += i*j

print(ans)

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    ans = sum([a * b for a, b in itertools.combinations(d, 2)])
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# print(N)
# print(d)

result = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if i > j:
            continue
        # print('{}, {}'.format(i, j))
        result += d[i] * d[j]
        
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

def double(n):
  return n**2

points = list(map(int, input().split( )))
points_2 = sum(list(map(double, points)))

total = list()

for i in range(n):
  for j in range(n):
    total.append(points[i] * points[j])

print(round((sum(total)-points_2)/2))

Submission status: Accepted

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

to = 0

ny = 0
for x in range(n):
    ny +=1
    for y in range(ny,n):
        #print (x,y)
        to += h[x]*h[y]

print (to)

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:
# -*- coding: utf-8 -*-
N = int(input())
d = [int(i) for i in input().split()]

import itertools
X = list(itertools.combinations(range(N), 2))

Y = 0
Z = int(N * (N - 1) / 2)
for i in range(Z):
    Y += d[X[i][0]] * d[X[i][1]]
print(Y)

Submission status: Accepted

Solution code:
import itertools
import sys
input = sys.stdin.readline
A = 0
N = int(input())

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

for v in itertools.combinations(O, 2):
  A = A + (v[0] * v[1])
print(A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import itertools

boxes = []
data = []

for i in itertools.combinations(box, 2): 
    boxes.append(i)

for k in boxes:
    data.append(k[0] * k[1])

i = 0 

for r in data:
    i = r + i 

print(i)

Submission status: Accepted

Solution code:
N = int(input())
d = list(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())
list_d = list(map(int, input().split()))

total = 0

for first in range(len(list_d)):
  for second in range(len(list_d)):
    if first < second:
      total += list_d[first] * list_d[second]

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    dn = list(map(int, args[1].split()))

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

    return str(s)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))

Submission status: Accepted

Solution code:
def solve_b(n, d_list):
    s1 = sum(d_list)
    s2 = sum([d ** 2 for d in d_list])
    res = (s1 ** 2 - s2) // 2
    return res


def main():
    n = int(input())
    d_list = list(map(int, input().split()))
    res = solve_b(n, d_list)
    print(res)


def test():
    assert solve_b(3, [3, 1, 2]) == 11
    assert solve_b(7, [5, 0, 7, 8, 3, 3, 2]) == 312


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools

N = int(input())
ds = [int(k) for k in input().split()]

L = itertools.combinations(range(N), 2)
sum = 0
for l in L:
    sum += (ds[l[0]] * ds[l[1]])

print(sum)

Submission status: Accepted

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

ans = 0
for a, b in enumerate(li):
  for c in li[a+1:]:
    ans += b * c
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

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

for t in Taco:
  ans += t[0] * t[1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Takoyaki(N, d):
    sum = 0
    for i in range(N):
        for j in range(N-i-1):
            sum += d[i] * d[i+j+1]
    return sum

N = int(input())
d = [int(x) for x in input().split()]
print(Takoyaki(N, d))

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

while len(tastes)>0:
    x = tastes.pop()
    for y in tastes:
        ans += x * y
            
print(ans)

Submission status: Accepted

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

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=input().split()
di=[]
for i in range(N):
    di.append(int(d[i]))

result=0
for i in range(N):
    for j in range(N):
        if i!=j:
            tmp=di[i]*di[j]
            result+=tmp
print(int(result/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

p = list(itertools.permutations(ds, 2))

goukei=[]

for i in p:
    goukei.append(i[0]*i[1])

print(sum(goukei)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
a=int(0)
i=int(0)
while i<n:
	a=a+d[i]
	i=i+1
a=a*a
i=int(0)
while i<n:
	a=a-d[i]*d[i]
	i = i+1
a=a/2
a=int(a)
print(a)

Submission status: Accepted

Solution code:
N=int(input())
from itertools import combinations
ds = list(map(int,input().split()))
a = 0
for d1, d2 in combinations(ds, 2):
    a += d1*d2
print(a)

Submission status: Accepted

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

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


print(kaifuku)

Submission status: Accepted

Solution code:
N = int(input())

D = list(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(" ")) )

helth = 0

for x in range(0,len(d)):
    for y in range(0,len(d)):
        if x!= y:
            helth += d[x]*d[y]
            
print(int(helth/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d_=list(map(int,input().split(" ")))
ans=0
while len(d_)!=0:
	x=d_[0]
	d_.pop(0)
	for i in d_:
		ans+=x*i


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
listed = list(map(int,input().split()))
sum_ = 0
for x in listed:
    sum_ -= x*x
    for y in listed:
        sum_ += x*y
print(sum_ // 2)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
cur = res = 0
for e in map(int, input().split()):
    res += e * cur
    cur += e
print(res)

Submission status: Accepted

Solution code:
N = int(input())
lists = list(map(lambda x: int(x), input().split()))
sum = 0

for index, i in enumerate(lists):
  if(index+1 >= len(lists)):
    break
  tmp_list = lists[index+1:len(lists)]
  for t in tmp_list:
    sum += t*i
      
print(sum)

Submission status: Accepted

Solution code:
N=int(input())
li = list(map(int,input().split()))	
cnt=0
for i in range(N):
  for j in range(N):
    Q=li[i]*li[j]
    cnt+=Q
lick=[li[i]*li[i] for i in range(N)]
w=sum(lick)
print(int((cnt-w)/2))

Submission status: Accepted

Solution code:
N = int(input())
d = [int(i) for i in 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:
N = int(input())
d = list(map(int, input().split()))
ans=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sum = 0
N = int(input())
d = list(map(int ,input().split()))
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:
a = int(input())
b = list(map(int,input().split()))
tairyoku_sum = 0
sel1 = 0
sel2 = 0
for val in range(a):
    sel1 = val
    sel2 = val+1
    for val2 in range(a-val-1):
        tairyoku_sum += b[sel1]*b[sel2]
        sel2 += 1
print(tairyoku_sum)

Submission status: Accepted

Solution code:
# coding: utf-8
yaki_num = int(input())
oisisa = list(int(i) for i in input().split())
hp = 0
for i in range(yaki_num):
  for j in range(i+1, yaki_num):
    hp += oisisa[i] * oisisa[j]
print(hp)

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

print(sum)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

for i in range(N):
  n = n - 1
  for j in range(n):
      r = r + (A[i] * A[i+j+1])

print(r)

Submission status: Accepted

Solution code:
def main():
    number_of_takoyakis = int(input())
    takoyaki_list = list(map(int,input().split()))
    cure_list = []
    for i in range(number_of_takoyakis):
        for j in range(number_of_takoyakis):
            if i != j:
                cure_list.append(caliculate_cure_point(takoyaki_list[i],takoyaki_list[j]))
    print(sum(cure_list)//2)

def caliculate_cure_point(takoyaki1,takoyaki2):
    return takoyaki1*takoyaki2

main()

Submission status: Accepted

Solution code:
import itertools
n=int(input())
d=[int(_) for _ in input().split()]
cross=0
l=list(itertools.combinations(d,2))
for i in range(len(l)):
	cross += l[i][0]*l[i][1]
print(cross)

Submission status: Accepted

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

for i in range(0, N):
	for j in range(0, N):
		TTL += d[i]*d[j]
		if i == j:
			TTL_odd += d[i]*d[j]
			
print(int((TTL-TTL_odd)/2))

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in 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:
import numpy as np

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

for i in range(n):
	for j in range(1,n):
		if j>i:
			s1=d[i]*d[j]
			s+=s1

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(A)):
    for j in range(1+i, len(A)):
        try:
            total += A[i]*A[j]
        except:
            pass
print(total)

Submission status: Accepted

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

gogei = 0

for i in range(len(d)):
    hei=  d[i] * sum(d[i+1::])
    gogei = gogei + hei
print(gogei)

Submission status: Accepted

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

import itertools

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

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()))
s=0
k=1

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