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

Submission status: Accepted

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

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

comb = combinations(d, 2)
amount = 0
for d1, d2 in comb:
    amount += d1 * d2
    
print(amount)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
d = np.array(list(map(int, input().split())))
print(sum(sum(np.triu(d[:, np.newaxis] * d, k = 1))))

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=[0]*n
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:
#ABC143.B
N = int(input())
d = list(map(int,input().split()))
c = 0
for i in range(N):
    for m in range(N-1-i):
        c +=d[i]*d[m+i+1]
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(x) for x in input().split()]
ans = 0
for i in range(n):
    for j in range(n):
        if i>j:
            ans += d[i]*d[j]

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations


def solve():
    n = int(input())
    D = map(int, input().split())

    dct = {}
    sm = 0
    for a, b in combinations(D, 2):
        sm = sm + a * b
    print(sm)


if __name__ == '__main__':
    solve()

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 = list(map(int, input().split()))
S = list(itertools.accumulate(D))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
from itertools import product
sum1 = 0
for i in product(L,repeat =2):
    #print(i)
    if i[0] != i[1]:
        sum1 += (i[0]*i[1])
#print(sum1//2)
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        #print(i,j)
        ans += L[i]*L[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()))
sum =0
for i,dx in enumerate(d):
    if i+1 <len(d):
        for k,dy in enumerate(d[i+1:]):
            sum+=dx*dy

print(sum)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

print(result)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

power=0

for i in range(n):
  for j in range(n):
    if i!=j:
      power+=dd[i]*dd[j]
print(power//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(n-i-1):
        ans += d[i]*d[i+j+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()))
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())
l = list(map(int, input().split()))
l2 = []
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())
dlist = list(map(int,input().split()))
anslist = list(dlist[i]*dlist[j] for i in range(n) for j in range(i+1,n))
print(sum(anslist))

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = (sum(d)) ** 2

for dd in d:
  ans -= dd ** 2

print(ans//2)

Submission status: Accepted

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

for i in range(n):
  for k in range(n):
    if i == k:
      continue
    else:
      total += d[i] * d[k]
      
print(total//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
import math
# mod = 10**9 + 7

n = int(input())
d = list(map(int, input().split()))
# n = int(input())
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 = input()
l = map(int,raw_input().split())
a = 0
for i in xrange(n):
    for j in xrange(i+1,n):
        a +=  l[i]*l[j]
print a

Submission status: Accepted

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

s = (sum(D)**2 - sum(d*d for d in D))//2


print(s)

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()))
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:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import itertools as it

def main():
    N = int(input())
    ds = input_nums()
    total = 0
    dd = it.permutations(ds, 2)
    for d in dd:
        total += d[0] * d[1]
    print(total//2)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tako = int(input())
tako_oisisa =  [int(i) for i in input().split()]
answer = 0
for i in range(tako):
  for s in range(tako):
    if i == s:
        continue
    else:
        answer += tako_oisisa[i]*tako_oisisa[s]
print(int(answer/2))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
d =list(map(int,input().split()))
h = 0
for i in range(N-1):
    x = d.pop(0)
    h += x*sum(d)
print(h)

Submission status: Accepted

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

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

Submission status: Accepted

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

l_a = [k * j for i, k in enumerate(l) for j in l[i + 1:]]

print(sum(l_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())
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)

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

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

for i in range(n):
  ans -= d[i] ** 2

print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
d = list(map(int,input().split()))
print(int((np.sum(np.array(d))**2 - np.sum(np.array(d)**2)) /2))

Submission status: Accepted

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

N = int(input().strip())
d_list = list(map(int, input().rstrip().split()))
#-----

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

print(sum)

Submission status: Accepted

Solution code:
#a,b = map(int,input().split())
#A = list(map(int,input().split()))
# S = str(input())
# if('L' in S[0::2] or 'R' in S[1::2]):
#     print('No')
# else:
#     print('Yes')
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:
#143_B
n = int(input())
d = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
out = 0
num = int(input())
kaihukuryou = list(map(int, input().split()))
kumiawase_sum = num * (num - 1) / 2
for i in range(num - 1):
  for j in range(i,num - 1):
    out = out + kaihukuryou[i] * kaihukuryou[j + 1]
print(out)

Submission status: Accepted

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

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=list(map(int,input().split()))
from itertools import combinations
comb=combinations(D, 2)
ans=0
for c in comb:
    ans+=c[0]*c[1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
List=[int(i) for i in input().split()]
ans=0
for i in range(0,n-1):
  for r in range(i+1,n):
    a=List[i]
    b=List[r]
    ans=ans+a*b
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:
a = int(input())
b = [int(x) for x in input().split()]

def pairs1(b, pairs=[], func=lambda x,y: x*y):
  if b == []:
    return pairs
  return pairs1(b[1:], pairs+[func(b[0], x) for x in b[1:]])

print(sum(pairs1(b)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

L = [d[x]*d[y] for x in range(N) for y in range(x+1,N)]
print (sum(L))

Submission status: Accepted

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

for x in range(len(d)):
    for y in range(x+1,len(d)):
        sum += d[x]*d[y]
print(sum)

Submission status: Accepted

Solution code:
from itertools import combinations

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

l = [x * y for x, y in combinations(d, 2)]
print(sum(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(N):
        if i!=j:
            ans += d[i]*d[j]

print(int(ans/2))

Submission status: Accepted

Solution code:
from itertools import combinations

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    c = 0
    for a, b in list(combinations(A, 2)):
        c += a*b

    return c

print(solve())

Submission status: Accepted

Solution code:
import itertools

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

P = itertools.combinations(D,2)
sum = 0
for p in P:
  sum += p[0]*p[1]
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(N-i-1):
        sum += D[i]*D[i+j+1]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

su = 0

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

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()))
comb = combinations(d, 2)
ans = [i[0]*i[1] for i in comb]
print(sum(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:
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 12 01:42:08 2020

@author: Kanaru Sato
"""

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

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

print(energy)

Submission status: Accepted

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

for i in range(N):
    for j in range(N):
        if i!=j:
            S+=int(d[i])*int(d[j])

S = S//2

print(S)

Submission status: Accepted

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

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

print(out)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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()))
comb = itertools.combinations(list(d), 2)
a = 0
for i,j in comb:
    a += i*j
print(a)

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:
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrD = np.array(input().split(),dtype=np.int64)

AA,BB = np.meshgrid(arrD,arrD)
a = np.dot(AA.flatten(),BB.flatten())
# print(a)
b = sum(arrD**2)
# print(b)

ans = (a-b)//2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = list(int(x) for x in input().split())

import itertools

total = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
hp = 0
takoyaki = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import itertools

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

    result = 0

    for i in itertools.permutations(d,2):
        result += i[0] * i[1]

    print(result // 2)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    l= list(map(int, input().split()))
    s=sum(l)
    a=0
    for i in range(n):
        a+=l[i]*(s-l[i])
    print(a//2)
    return
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(x) for x in input().split()]
D.sort(reverse=True)
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())
numbers = input().split(" ")
total = 0
d = 0
for i in numbers:
    d += int(i)**2
    s = 0
    for j in numbers:
        s += int(j)
    total += s*int(i)
ans = total - d
print(int(ans/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


sum = 0
for count1 in range(N-1):
    for count2 in range(count1+1,N):
        sum = sum  + D[count1]*D[count2]

print(sum)

Submission status: Accepted

Solution code:
input(); s=t=0
for i in map(int,input().split()): s+=i*i; t+=i
print(t*t-s>>1)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

for i in range(len(d)):
    for j in range(i+1,len(d)):
        d_new.append(d[i]*d[j])

print(sum(d_new))

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:
import itertools
N = int(input())
l = list(map(int,input().split()))
a = 0
for i,j in itertools.combinations(l,2):
  a += i*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())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[n]*List[m]
print(Sum)

Submission status: Accepted

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

t=0
for hp in [[x*y for y in d] for x in d]:
    # print(hp)
    t+=sum(hp)
kaburi=[i*i for i in d]
print((t-sum(kaburi))//2)

Submission status: Accepted

Solution code:
import sys
import math
#a,b= map(int,input().split())
a=int(input())
li= [int(x) for x in input().split()]
i=j=sum=0
for i in range(len(li)-1):
  for j in range(len(li)-i-1):
    sum+=li[i]*li[i+j+1]
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:
from sys import stdin
import itertools

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

heal = itertools.combinations(d, 2)

total = 0
for i in list(heal):
    total += i[0] * i[1]

print(total)

Submission status: Accepted

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

ans = 0

for n in range(N):
    for i, d in enumerate(D):
        if i == n:
            continue
        else:
            ans += d * D[n]
print(int(ans/2))

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


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

n, *d = map(int, read().split())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


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

ans = 0

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

print(ans)

Submission status: Accepted

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

s = 0
for i in range(0, n - 1):
    s += power[i] * sum(power[i + 1 : n])
print(s)

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

p = itertools.combinations(d, 2)
ans = 0
for i, j in p:
    ans += i * j
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dLst = list(map(int, input().split()))
dLst.sort()
ans = 0
for i in range(n):
    for ii in range(i, n):
        if i < ii:
            ans += dLst[i] * dLst[ii]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
dLst = list(input().split())
dLst.sort()
ans = 0
for i in range(n):
    for ii in range(i, n):
        if i < ii:
            ans += int(dLst[i]) * int(dLst[ii])
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-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):
    a = d[i]
    c += d[i] * (sum(d)-a)

print(c//2)

Submission status: Accepted

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

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

def main():
    n = int(input())
    d = list(map(int,ipti().split()))
    ans = 0

    for i in range(n-1):
        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=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()))
c = 0
for i1, j1 in enumerate(d):
    for i2, j2 in enumerate(d):
        if i1 == i2:
            continue
        else:
            c += j1 * j2
print(c // 2)