Problem:


Score : 200 points

Problem Statement

It's now the season of TAKOYAKI FESTIVAL!

This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.

As is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \times y health points.

There are \frac{N \times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \frac{N \times (N - 1)}{2} values.

Constraints

All values in input are integers.

2 \leq N \leq 50

0 \leq d_i \leq 100

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

Print the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.

Sample Input 1

3
3 1 2

Sample Output 1

11

There are three possible choices:

Eat the first and second takoyaki. You will restore 3 health points.

Eat the second and third takoyaki. You will restore 2 health points.

Eat the first and third takoyaki. You will restore 6 health points.

The sum of these values is 11.

Sample Input 2

7
5 0 7 8 3 3 2

Sample Output 2

312



Sample input:
3
3 1 2


Sample output:
11

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = [int(_) for _ in input().split()]
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	# n,m = map(int,input().split())
	n = int(input())
	# s = str(input())
	a = list(map(int,input().split()))
	# l = [list(map(int, input().split())) for _ in range(n)]
	import itertools

	kumi = list(itertools.combinations(a,2))
	# print(kumi)
	ans = 0
	for i in kumi:
		ans += i[0] * i[1]

	print(ans)



if __name__ == '__main__':
	main()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, d: "List[int]"):
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            # print(i, j@)
            ans += d[i]*d[j]

    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()))
result=0

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

Submission status: Accepted

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

s = 0
for i, di in enumerate(d):
    for dj in d[i+1:]:
        s += di * dj
print(s)

Submission status: Accepted

Solution code:
num = int(input())
data = input().split(' ')
data_int = [int(data[i]) for i in range(num)]

result = 0

for i in range(num):
    for l in range(num - i - 1):
        result += data_int[i] * data_int[l + i + 1]

print(result)

Submission status: Accepted

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

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

print(x)

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


N = int(input())
d = [inp for inp in map(int, input().split())]

ret = 0
for pair in combinations(d, 2):
  ret += pair[0] * pair[1]
  
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(N-1):
    t = D[i]
    for d in D[i+1:]:
        c += t * d

print(c)

Submission status: Accepted

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

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(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()))
count = 0
seen =[]
for i in range(N - 1):
    for j in d[i+1:]:
        count += d[i] * j
        
print(count)

Submission status: Accepted

Solution code:
input()
A = list(map(int,input().split()))
b = 0
while A:
  a = A.pop(0)
  for i in A:
    b += i * a
print(b)

Submission status: Accepted

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

Submission status: Accepted

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

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]+ans

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

c = 0

for i in range(n):
    for j in  range(n):
        if i == j:
            break
       
        c += l[i]*l[j]
        

print(c)

Submission status: Accepted

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

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

answer = 0
for i in combinations:
    answer += int(i[0]) * int(i[1])

print(answer)

Submission status: Accepted

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

for i in range(n):

    x += lst[i]*sum(lst[i+1:n])

print(x)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

d1 = []
for i in combinations(d,2):
    d1.append(i[0]*i[1])

print(sum(d1))

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:
import itertools
N = int(input())
sum = 0
li = [0]*N
for i in range(N):
    li[i] = i+1
li_d = list(map(int, input().split()))
li_comb = list(itertools.combinations(li, 2))
for tpl in li_comb:
    sum += li_d[tpl[0]-1]*li_d[tpl[1]-1]
print(sum)

Submission status: Accepted

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

health = []
for i in range(len(a)):
    for j in range(i+1, len(a)):
        health.append(a[i] * a[j])

print(sum(health))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(life)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#全探索のforが書けますか？という問題
n=int(input())
*l,=map(int,input().split())
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=l[i]*l[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):
        if i!=j:
            ans+=d[i]*d[j]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i, di in enumerate(d):
    for j, dj in enumerate(d):
        if i > j:
            ans += di * dj

print(ans)

Submission status: Accepted

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

print(output)

Submission status: Accepted

Solution code:
cnt=int(input())
takoyaki=[int(i) for i in input().split()]

ans=0


for j in range(cnt-1):
    
    for k in range(j+1,cnt):
        
        ans+=takoyaki[j]*takoyaki[k]
        
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
n = int(input())

d = list(map(int, sys.stdin.readline().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:
from sys import stdin

n = int(stdin.readline().rstrip())
arr = [int(x) for x in stdin.readline().rstrip().split()]

sum = 0
for i,stndrd in enumerate(arr):
    for other in arr[i+1:]:
        sum += stndrd*other

print(sum)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
for elms in list(itertools.combinations(d, 2)):
    ans += elms[0]*elms[1]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    s=sum(A)
    t=sum(a**2 for a in A)
    print((s**2-t)//2)
resolve()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
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=[int(i) for i in input().split()]
X=sum([i*i for i in d])
print((sum(d)**2-X)//2)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

print(sum)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline())
xs = [int(s) for s in sys.stdin.readline().split(" ")]

result = 0

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

ret = 0

for i in range(N):
    for j in range(i+1, N):
        if i == j:
            continue

        ret += D[i] * D[j]

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
LEN = int(((N*(N-1))/2))


ans = []

for i in range(N):
    for j in range(N):
        if i != j:
            ANS = (d[i]*d[j])
            ans.append(ANS)
            
        
        
print(int(sum(ans)/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())

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

combi = list(itertools.combinations(d,2))
k = len(combi)
s=0
for i in range(k):
    s += (combi[i])[0] * (combi[i])[1]

print(s)

Submission status: Accepted

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

i=0

while i<len(de):
	j=i+1
	while j<len(de):
		total+=de[i]*de[j]
		j+=1
	i+=1
	
print(total)

Submission status: Accepted

Solution code:
input()
l=list(map(int,input().split()))
a=0
for _ in l:
    a+=_*(sum(l)-_)
print(a//2)

Submission status: Accepted

Solution code:
import sys
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    t = 0
    for v in itertools.combinations(a, 2):
        t += v[0] * v[1]
    print(t)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(R)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
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:
from itertools import combinations
from operator import mul

input()
print(sum(mul(*takoyaki) for takoyaki in combinations(map(int, input().split()), 2)))

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N=int(input())

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

result=0

for x in list(itertools.combinations(tako,2)):
    result += x[0]*x[1]

print(result)

Submission status: Accepted

Solution code:
N=int(input())
tako=list(map(int,input().split()))
power=0

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

cumsum = 0
for n in range(N):
    cumsum += d[n]
sub_cumsum = 0
ans = 0
for n in range(N):
    sub_cumsum += d[n]
    ans += d[n] * (cumsum-sub_cumsum)
print(ans)

Submission status: Accepted

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

import numpy as np
d = np.array(d)

print( ( (np.sum(d))**2 - np.sum(d**2) ) // 2 )

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

num = int(input())
tako = list(map(int, input().split()))
ans=0
for index1 in range(num-1):
	for index2 in range(index1+1,num):
		sum = tako[index1]*tako[index2]
		#print(sum)
		ans = ans+sum
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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

print(ans)

Submission status: Accepted

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

def main():
    n = int(input())
    t = tuple(map(int, input().split()))
    print(sum([t[i] * t[j] for i in range(n) for j in range(i+1, n)]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def main():
    n = int(input())
    t = tuple(map(int, input().split()))
    print(sum([t[i] * t[j] for i in range(n) for j in range(i, n) if i != j]))

if __name__ == '__main__':
    main()

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

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

from itertools import combinations
import numpy as np
sum=0
base = list(combinations(d,2))
for i in range(len(base)):
    sum+=base[i][0]*base[i][1]

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d_lis = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(n):
    for v in range(n):
        if i == v:
            pass
        else:
            tmp = d_lis[i] * d_lis[v]
            ans += tmp
print(ans//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 itertools
n = int(input())
d = [int(i) for i in input().split()]

c = list(itertools.combinations(d,2))
ans = 0 
for x,y in c:
    ans += x * y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    combi = itertools.combinations(d, 2)
    sum = 0
    for item in combi:
        sum += item[0] * item[1]
    print(sum)
    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()))
print(sum([d[i]*d[j] for i in range(n-1) for j in range(i+1,n)]))

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

cand = []
for x, y in combinations(D, 2):
    cand.append(x * y)

ans = sum(cand)
print(ans)

Submission status: Accepted

Solution code:
from itertools import *

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

total = 0
for pat in combinations(range(n), 2):
    total += ds[pat[0]] * ds[pat[1]]
print(total)

Submission status: Accepted

Solution code:
from functools import reduce
from operator import add

n = int(input())
l1 = [int(i) for i in input().split()]
print(reduce(add, [l1[a]*l1[b] for a in range(n-1) for b in range(a+1,n)]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    t = d.pop(0)
    ans += t*sum(d)

else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0

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