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: Wrong Answer

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

s = 0
for i in range(n):
    for j in range(n):
        if i != j:
            s += (i+1)*(j+1)

print(s // 2)

Submission status: Wrong Answer

Solution code:
import itertools

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

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

Submission status: Wrong Answer

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

def sum_(N, D):
    total = 0
    for i in range(N):
        for j in range(i+1, N):
            total = total + (D[i] * D[j])
    return total

sum_(N, D)

Submission status: Wrong Answer

Solution code:

N = int(input())

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


sum = 0
for i1 in range(len(l)):
    for i2 in range(i1+1, len(l)):
        print("i1 {} i2 {}".format(l[i1], l[i2]))
        sum += l[i1] * l[i2]

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tako_set = set()
for i in range(n):
	for j in range(i+1, n):
		tako_set.add(takos[i]*takos[j])
print(sum(tako_set))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# abc143/abc143_b
import sys
from itertools import product

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    d = i2nn()
    r = 0
    for i, j in product(range(N), range(N)):
        r += d[i] * d[j] if i == j else 0
    print(r)
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(su)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations as C

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

D = list(C(d, 2))

ans = 0

for i in D:
    ans += i[0] * i[1]

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int, input().split()))
ans=0
for i in range(n-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 = list(map(int,input().split()))
c = combinations(d,2)
sumd = 0
for x,y in c:
    sumd += x*y
print(sumd)

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

Submission status: Accepted

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

# i個目のたこ焼のうまさDi
# おいしさがx,yのたこやき2個を食べると体力がxy回復
total = 0
for i,x in enumerate(D[:-1]):
  for y in D[i+1:]:
    total += x * y
print(total)

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(0,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(x) for x in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

takocombi=list(itertools.combinations([i for i in range(N)],2))

ans=0
for h in range(len(takocombi)):
	ans+=D[takocombi[h][0]]*D[takocombi[h][1]]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(N):
  for j in range(N):
    if i != j:
      ans += d[i]*d[j]
      
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d  = [int(n) for n 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(map(int, input().split()))
a = 0
for i in range(n):
    for j in range(n):
        if i != j:
            a += d[i] * d[j]
print(a // 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
from itertools import combinations
for i, j in combinations(range(N), 2):
    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()))
ans = 0
sum = sum(d)
for i in d:
    sum -= i
    ans += i*sum
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

Submission status: Accepted

Solution code:
from itertools import permutations
n = int(input())
d = [int(i) for i in input().split()]
t = sum([i[0] * i[1] for i in permutations(d, 2)]) // 2
print(t)

Submission status: Accepted

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

Submission status: Accepted

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

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:
# l,r,d =map(int, input().split()))
n = int(input())
d = list(map(int, input().split()))

# s = [map(int, input()) for i in range(3)]
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):
    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()))
from itertools import combinations
ans = 0
for i , j in combinations(D,2):
    ans += i*j
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
from itertools import accumulate
print(sum(list(d*c for d, c in zip(D[1:], accumulate(D)))))

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

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) for j in range(i+1,N)]))

Submission status: Accepted

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

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


n = 0

for i in range(len(p)):
    n = n + (p[i][0] * p[i][1])
    
A = int(n/2)
print(A)

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
dlst = list(map(int, input().split()))
ans = 0
for i in range(len(dlst)-1):
    k = dlst.pop()
    ans = ans + k*sum(dlst)

print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
d = list(map(int, input().split()))
M = []
ans = 0

for v in itertools.combinations(d, 2):
    M.append(list(v))

for m in M:
    ans += m[0]*m[1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
d=list(map(int,input().split()))
ans=0
for i in range(len(d)-1):
    for j in range(i+1,len(d)):
        ans+=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()))

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

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

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

print(sam)

Submission status: Accepted

Solution code:
import itertools
total = 0
recovery = 0
n = int(input())
di = list(map(int, input().split()))
for x in itertools.combinations(di, 2):
  #print(x)
  recovery = x[0] * x[1]
  total += recovery
  #print(total)
print(total)

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())
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:
from itertools import combinations
input()
d = list(map(int,input().split()))
comb = combinations(d,2)
dsum = 0
for a,b in comb:
    dsum += a*b

print(dsum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    readline = sys.stdin.buffer.readline

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

    e = sum(d)
    ans = 0
    for i in d:
        e -= i
        ans += i*e
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, d: "List[int]"):
    return sum(x * y for x, y in its.combinations(d, 2))


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(f'{solve(N, d)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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


for i in range(0, n-1):
  for t in range(i+1, n):
    con = lis[i] * lis[t]
    ans += con
    

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

answer = 0
for num1 in range(0, len(arr) - 1):
    for num2 in range(num1+1, len(arr)):
        answer += (arr[num1] * arr[num2])

print(answer)

Submission status: Accepted

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

ans = 0

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

print(ans//2)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

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

pattern = itertools.combinations(a,2)
total = 0
for i,j in pattern:
    total += i*j
print(total)

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(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()))
sumd = sum(d)
d_2 = sum([i * i for i in d])
print((sumd*sumd-d_2)//2)

Submission status: Accepted

Solution code:
N = int(input())

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

for i in range(N):
    for j in range(N):
        if i != j:
            ans += dn[i] * dn[j]
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
a=int(input())
b=0
c=list(map(int,input().split()))
for i in range(a):
  for k in range(a):
    b=b+c[i]*c[k]
for u in range(a):
  b=b-c[u]*c[u]
print(int(b/2))

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    ans = 0

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
d=[int(s) for s 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:
from itertools import combinations
import numpy as np
N = int(input())
D = list(map(int, input().split()))
List = np.array(list(combinations(D,2)))
print(sum(np.product(List, axis = 1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
D = list(map(int, input().split()))
x = combinations(D, 2)
ans = 0

for i, j in x:
    ans += i*j
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(x) for x in input().split()]
ans=0
import itertools
# (1,2,3),(1,2,4),---,(7,8,9)
for seq in itertools.combinations(range(len(d)),2):
    ans+=d[seq[0]]*d[seq[1]]
print(ans)

Submission status: Accepted

Solution code:
# 問題：https://atcoder.jp/contests/abc143/tasks/abc143_b

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

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

result = 0
for c in combinations(d, 2):
    result += c[0] * c[1]

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

A = sum(D)**2 - sum([d*d for d in D])

print(A//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
ds = list(map(int, input().split()))
DC = list(itertools.combinations(ds, 2))
L = 0
for i in DC:
	L += i[0]*i[1]
print(L)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d_lst = list(map(int, input().split()))
    sum_d_lst = sum(d_lst)
    ans = 0

    for i in range(n):
        ans += d_lst[i] * (sum_d_lst - d_lst[i])

    print(ans // 2)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    print(ans)


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

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

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


d = list(itertools.combinations(D,2))
cnt = 0
for i in d:
    cnt += i[0] * i[1]
print(cnt)

Submission status: Accepted

Solution code:
import itertools
import math

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


import itertools

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

ans=0

for pp in p:
  ans+=d[pp[0]]*d[pp[1]]

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

ans_lists = []
for v in itertools.combinations(tastes, 2):
    cure = v[0]*v[1]
    ans_lists.append(cure)

ans = 0
for i in ans_lists:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

def mapt(fn, *args):
    return tuple(map(fn, *args))

n = int(input())
d = mapt(int, input().split(" "))

print(sum(d[a]*d[b] for a, b in combinations(range(n), 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:
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=[int(i) for i in input().split()]
sum_list=[]


for i in range(n):
    for j in range(i+1,n):
        
        sum_list.append(d_list[i]*d_list[j])
        

print(sum(sum_list))

Submission status: Accepted

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