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

for i in range(N):
    for j in range(N):
        if (i != j):
            kaihuku = d_list[i]*d_list[j]
            ans += kaihuku

print(int(ans/2))

Submission status: Accepted

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

import itertools
cmb_d = list(itertools.combinations(d_i, 2))

sum =0
for cmb in cmb_d:
  sum += cmb[0] * cmb[1]

print(sum)

Submission status: Accepted

Solution code:
import sys
import itertools
n = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))
total =0
L = list(itertools.combinations(L, 2))
for ele in L:
    total +=ele[0]*ele[1]
print(total)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int,input().split()))
import itertools
ans = 0
for l in list(itertools.combinations(D,2)):
    x, y = l
    ans += x*y
print(ans)

Submission status: Accepted

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

num = len(D)

total = 0
for i in range(num):
    d1 = D[i]
    for j in range(i + 1, num):
        d2 = D[j]

        total += d1 * d2

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

N = int(input())
dlist = inpl()

ans = 0

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

print(ans)

Submission status: Accepted

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

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

print(ret)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#import heapq
import itertools
#import math
#import numpy as np
import sys

N = int(input())
D = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()
P = list(itertools.combinations(list(range(N)),2))
ans = 0
for p in P :
    #print(p)
    a = D[p[0]] * D[p[1]]
    ans += a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

tako_list = list(map(int, input().split()))
tako_len = len(tako_list)

sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
import sys
import math
import numpy as np
import itertools

# ひとつ入力
n = int(input())

# 空白区切りの数列をリストに代入
d = [int(i) for i in input().split()] 

sum_all = 0
sum2_all = 0
for i in range(n):
    sum_all += d[i]
    sum2_all += d[i]*d[i]

print( (sum_all*sum_all - sum2_all)//2)

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

print(ans)

Submission status: Accepted

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

print(score)

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

print(total)

Submission status: Accepted

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

total_sum = 0
for i, vald in enumerate(d):
    e = d[i+1:]

    for vale in e:
        total_sum += vald * vale
print(total_sum)

Submission status: Accepted

Solution code:
from itertools import combinations
def solve():
    n = int(input())
    D = list(map(int, input().split()))
    print(sum(x * y for x, y in combinations(D, 2)))
solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\143\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        n = int(self.input_data())
        tako = [int(i) for i in self.input_data().split()]
        result = 0

        for i in range(len(tako)):
            for j in range(len(tako)):
                if i < j:
                    result += tako[i] * tako[j]
                else:
                    continue

        print(str(result))

solver = B(REL_PATH)
solver.exec_resolve()

Submission status: Accepted

Solution code:
num =int(input())
tako = [int(s) for s in input().split()]
p=0
for i in range(num):
  for j in range(num - i -1):
    p += tako[i]*tako[j+i+1]
print(p)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

def main():
    input = sys.stdin.readline
    N = int(input())
    d = list(map(int, input().split()))

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

    return ans

if __name__ == '__main__':
    print(main())

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

Submission status: Accepted

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

value = 0
value2 = 0

for i in range(N):
    for j in range(N):
        value = value + d[i]*d[j]
        
for i in range(N):
    value2 = value2 + d[i]*d[i]
    
print(int((value-value2)/2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

mypow = 0

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


print(mypow)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = list(map(int, input().split()))
sum = 0
cmb = list(itertools.combinations(d, 2))
for case in cmb:
    sum += case[0]*case[1]

print(sum)

Submission status: Accepted

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

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
t = 0
for i in a:
    t+=i**2
    for j in a:
        ans+=i*j
print(int((ans-t)/2))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

tot = 0
for i in range(0, N - 1): # 0, 1, ..., N-2
    for j in range(i + 1, N): # i+1, i+2, ..., N-1
        tot += d[i] * d[j]

print(tot)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

tako_sum = 0
for i in range(N):
  for j in range(i, N):
    if i == j:
      continue
    tako_sum += d[i] * d[j]
print(tako_sum)

Submission status: Accepted

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

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

print(sum_val)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
#a,b = map(int,input().split())
a_L = list(map(int,input().split()))

ans_L = []

from itertools import product, permutations,combinations
for i in combinations(a_L,2):
    ans_L.append(i[0]*i[1])

print(sum(ans_L))

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import array
import math
import os
import sys


def main():
    N = read_int()
    D = read_ints()
    s = 0
    for i in range(N):
        for j in range(i + 1, N):
            s += D[i] * D[j]
    print(s)


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


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

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

ret=0
for i in range(n):
  for j in range(n):
    if i<j:
      ret += d[i]*d[j]
      



print(ret)

Submission status: Accepted

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

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


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()))
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:
def resolve():
    n = int(input())

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

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

    print(ans)

resolve()

Submission status: Accepted

Solution code:
from itertools import combinations

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

answer = sum(d1 * d2 for d1, d2 in combinations(d, 2))
print(answer)

Submission status: Accepted

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

dd=[d[0]]

for i in range(1,N):
    dd.append(dd[i-1]+d[i])

out=0

for i in range(N-1):
    out+=d[N-1-i]*dd[N-2-i]

print(out)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    s=0
    for i in range(N):
        s=s+d[i]*(sum(d)-d[i])
    print(int(s/2))
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

for n in range(N-1):
    ans += D[n] * sum(D[n+1:])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

#+++++
		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	ans=0
	for i, v in enumerate(al):
		for j, v2 in enumerate(al[i+1:]):
			#print(i,j,v,v2)
			ans+=v*v2
	print(ans)
	return 
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
O = list(map(int,input().split()))
A = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        else:
            A += O[i]*O[j]
print(A)

Submission status: Accepted

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

sum1 = 0
for i in range(N):
    sum1 = sum1 + d[i]

sum1 = sum1*sum1

sum2 = 0
for i in range(N):
    sum2 = sum2 + d[i]**2

print (sum1 - sum2)/2

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    d = [int(i) for i in input().split()]

    sum = 0

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

Submission status: Accepted

Solution code:

import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


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

    ans = []

    for x in range(N):
        for y in range(x + 1, N):
            ans.append(v[x] * v[y])

    print(sum(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

def B():
    n = input()
    d = list(map(int,input().split(" ")))
    temp = list(itertools.combinations(d,2))
    s = sum(list(map(lambda x:x[0]*x[1],temp)))
    print(s)

if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
a = int(input())
list = list(map(int, input().split(" ")))
sum = 0
for num_1, i in enumerate(list):
  for num_2, j in enumerate(list):
    if num_1 <= num_2:
      continue
    else:
      sum += i*j
print(sum)

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

Submission status: Accepted

Solution code:
import itertools


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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())
d = list(map(int, input().split()))
n_sum = 0
for n in range(N):
    for i in range(n+1, len(d)):
        n_sum += d[i] * d[n]

print(n_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    d = [int(i) for i in input().split()]
    ret = 0
    for i, v in enumerate(d):
        for j in d[i + 1:]:
            ret += v * j
    print(ret)

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

sum_up = 0
for i in range(len(li)):
    for j in range(i+1, len(li)):
        sum_up += li[i] * li[j]
print(sum_up)

Submission status: Accepted

Solution code:
import sys
import itertools

input = sys.stdin.readline


def main():
    n = int(input())
    d_list = map(int, input().split())
    hoge = 0
    for a, b in itertools.combinations(d_list, 2):
        hoge += a * b
    print(hoge)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0

for i in range(N):
	for j in range(N):

		if i >= j:
			continue
		else:
			ans += D[i] * D[j]

print(ans)

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
takos = list(map(int, raw_input().split(" ")))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())

lst = (map(int, input().split()))

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

aa = 0

for i in range(n):
    for j in range(i+1,n):
        aa += num[i]*num[j]
print(aa)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

combs = itertools.combinations(d, 2)
sum = 0
for a, b in combs:
    sum += a * b
print(sum)

Submission status: Accepted

Solution code:
from itertools import combinations

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


print(sum([a * b for a, b in combinations(ds, 2)]))

Submission status: Accepted

Solution code:
N = int(input())

D = input().split()

total = 0
for i in range(N):
	for j in range(N):
		if not i == j:
			total += int(D[i]) * int(D[j])
			
			
print(int(total/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

import sys


input = sys.stdin.readline


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for i, d1 in enumerate(dl):
  for j, d2 in enumerate(dl):
    if i == j:
      continue
    ans += (d1 * d2)
print(int(ans / 2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
d = list(map(int,input().split()))
d_sum = sum(d)
ans = 0
for i in range(n):
  d_sum -= d[i]
  ans += d[i]*d_sum
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
d_list=[int(i) for i in input().split()]
comb = list(itertools.combinations(d_list, 2))
sum_heal = 0
for i,j in comb:
    sum_heal += i*j
print(sum_heal)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
sumd = sum(d)

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
input()
d = [int(x) for x in input().split()]
print(sum(x * y for x, y in combinations(d, 2)))

Submission status: Accepted

Solution code:
N = int(input())
# n, *a = map(int, open(0))
# M, D = map(int, input().split())
D = list(map(int, input().split()))
# S = input()
cnt = 0
import itertools
l = list(itertools.combinations(D,2))
for t in l:
    cnt += t[0] * t[1]
print(cnt)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    d_list = [int(i) for i in input().split()]
    sum = 0

    for i, x in enumerate(d_list):
        for y in d_list[i + 1:]:
            sum += x * y
    print(sum)


if __name__ == "__main__":
    main()