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:
from itertools import combinations as cb
n = int(input())
l = [int(j) for j in input().split()]
m = cb(l, 2)
ans = 0
# print(m[0], m[5])
for i in m:
    # print(i)
    ans+=i[0]*i[1]
print(ans)

Submission status: Accepted

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

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()
    print(sum(a*b for a, b in combinations(d, 2)))
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
tmp = input()
d = [int(x.strip()) for x in tmp.split(' ')]
su = 0
sq = 0
for i in range(N):
    su = su + d[i]
    sq = sq + d[i]*d[i]
print(int((su*su-sq)/2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
d = np.fromiter(map(int, input().split()), np.int64)

s1 = np.sum(d)
s2 = np.sum(d * d)
print((s1 * s1 - s2) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

total = sum(D)
ans = 0
for d in list(D):
    ans += (total - d) * d
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

from itertools import combinations
ret = 0
for it in combinations(arr, 2):
    ret += (it[0]*it[1])
print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# ABC143 B

n = int(input())
d = list(map(int, 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:
from itertools import product
def tako(ds):
    products = [each[0]*each[1] for each in list(product(ds, ds))]
    self_sum = sum([item**2 for item in ds])
    return (sum(products) - self_sum)//2

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# n = int(input())
n = input()
# a,b,c = map(int, input().split())
d = list(map(int, input().split()))
sum = sum(d)
ans = 0
for i in d:
  ans += i * (sum - i)

print(int(ans/2))

Submission status: Accepted

Solution code:
import itertools

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

result = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(int((sum(d)**2 - pro)/2))

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline().strip())
D = [int(n) for n in sys.stdin.readline().strip().split()]

total = 0
for i in range(N):
  total += D[i]*sum(D[i+1:])
print(total)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
ds = map(int, input().split())
res = sum(map(lambda x: x[0] * x[1], combinations(ds, 2)))
print(res)

Submission status: Accepted

Solution code:
N = int(input())

tastes = [int(i) for i in input().split()]
total_tastes = sum(tastes)
total_squared = 0
for i in range(N):
    total_squared += tastes[i]**2
print((total_tastes**2-total_squared)//2)

Submission status: Accepted

Solution code:
a = input()

a = int(a)

b = input().split(' ')

from itertools import combinations

comb = combinations(b, 2)

sum = 0

for i in list(comb):
    sum += int(i[0])*int(i[1])

print(sum)

Submission status: Accepted

Solution code:
# B - TAKOYAKI FESTIVAL 2019
N = int(input())
d = list(map(int, input().split()))
tmp = 0


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

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from itertools import permutations, combinations,combinations_with_replacement,product
from fractions import Fraction as frac
import bisect
import heapq

import logging
logging.basicConfig(level=logging.DEBUG)

import sys
#input = sys.stdin.readline().rstrip

setrecursionlimit(1000000)

MOD = 10**9+7
INF = float('inf')

def main():
    N=int(input())
    D=[int(x) for x in input().split()]
    
    C=combinations(D,2)
    ans=0
    for c in C:
        ans+=c[0]*c[1]
    print(ans)
main()

Submission status: Accepted

Solution code:
import itertools

def main():
  n = int(raw_input())
  dishes = map(int, raw_input().split())
  result = 0
  for c in itertools.combinations(dishes, 2):
    result += c[0]*c[1]
  print(result)

main()

Submission status: Accepted

Solution code:
n = int(input())
numbers = [int(i) for i in input().split()]
total = 0
for x in range(len(numbers)):
    for y in range(x+1,len(numbers)):
        total+=numbers[x]*numbers[y]
print(total)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i in input().split(' ')]
Dsum = sum(D)
kaifuku = 0
for d in D:
    kaifuku += d*(Dsum-d)
print(kaifuku//2)

Submission status: Accepted

Solution code:
N = int(input())
heal = list(map(int, input().split()))
ans = 0

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
d = [int(e) for e in input().split()]


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

print(res)

Submission status: Accepted

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

sum = 0

for i in range(n):
    for j in range(i+1, n):
        sum += d_list[i] * d_list[j]
        #print(i, j, d_list[i]*d_list[j])
print(sum)

Submission status: Accepted

Solution code:
def solve(takoyakis):
    ans = 0

    for i, x in enumerate(takoyakis):
        for j, y in enumerate(takoyakis):
            if j <= i:
                continue
            ans += x * y

    return ans


if __name__ == "__main__":
    n = int(input())
    d_s = [int(d) for d in input().split(' ')]
    print(solve(d_s))

Submission status: Accepted

Solution code:
N=int(input())
d_list=[int(thing) for thing in input().split(" ")]

dd=sum([x*x for x in d_list])
s=sum(d_list)
S=s*s
ret=int(0.5*(S-dd))
print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
d_list = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    D = list(map(int, input().split()))

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


main()

Submission status: Accepted

Solution code:
import itertools
N = int(input())
d_list = list(map(int, input().split()))
c_d_list = list(itertools.combinations(d_list, 2))
answer = 0
for a in c_d_list:
    temp = a[0] * a[1]
    answer += temp
print(answer)

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

Submission status: Accepted

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

tot = sum(d)
res = 0

for i in range(N):
    tot -= d[i]
    res += tot * d[i]

print(res)

Submission status: Accepted

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

sums = 0
for i, x in enumerate(d_list):
  for j, y in enumerate(d_list):
    if i!=j:
      sums += x*y

print(int(sums/2))

Submission status: Accepted

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

sum=0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
ans = (sum(D) ** 2 - sum(list(map(lambda x: x ** 2, D)))) // 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d_list = list(map(int, input().split()))
total = 0
for i in range(N):
  for j in range(N):
    if i == j:
      pass
    else:
      total += d_list[i] * d_list[j]

print(total//2)

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''

n = int(stdin.readline().rstrip())
d = stdin.readline().rstrip().split()
res = 0
count1 = 0
for el1 in d:
    count2 = 0
    for el2 in d:
        if (count2 > count1):
            res += int(el1) * int(el2)
        count2 += 1
    count1 += 1

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
d = list(map(int,input().split()))
sum = 0

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

Submission status: Accepted

Solution code:
import itertools

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


if __name__ == "__main__":
    test()

Submission status: Accepted

Solution code:
N = int(input())
d_list = list(map(int, input().split()))
d_sum = 0
for i, x in enumerate(d_list):
    for j, y in enumerate(d_list[i+1:]):
        d_sum += x*y

print(d_sum)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
N = int(input())
D = [int(v) for v in sys.stdin.readline().split()]

l = [a * b for a, b in itertools.combinations(D, 2)]
print(sum(l))

Submission status: Accepted

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

print(sum_cure)

Submission status: Accepted

Solution code:

N = int(input())
D = input().split(' ')

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

print(a)

Submission status: Accepted

Solution code:
n1 = int(input())
d1 = [int(i) for i in input().split()]

r1 = 0

for i1 in range(n1 - 1):
    for i2 in range(n1 - i1 - 1):
        r1 += d1[i1] * d1[i2 + i1 + 1]

print(r1)

Submission status: Accepted

Solution code:
N = int(input())
l = list(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()))
import itertools
combi = itertools.combinations(d, 2)
wa = 0
for e in combi:
    wa += e[0]*e[1]
print(wa)

Submission status: Accepted

Solution code:
import sys

def solve(n, d):
  ans = 0
  for i, d_i in enumerate(d):
    for j, d_j in enumerate(d):
      if i == j:
        continue
      ans += d_i * d_j
        
  print(ans // 2)

if __name__ == '__main__':
  n = sys.stdin.readline().strip()
  d = list(map(int, sys.stdin.readline().strip().split(" ")))
  solve(n, d)

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

comb = list(itertools.combinations(range(n), 2))

print(sum([c[i[0]]*c[i[1]] for i in comb]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(N: int, d_li: "List[int]"):
    s = 0
    for i in range(N):
        di = d_li.pop()
        s += sum([di * d for d in d_li])
    print(s)


# Generated by 1.1.5 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()))

cnt = 0
for i in range(N):
    for j in range(i,N):
        if i == j:
            pass
        else:
            cnt += d[i] * d[j]

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    print((sum(D)**2 - sum(d**2 for d in D))//2)
    


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(N):
  S = S + D[i]

for i in range(N):
  Ans = Ans + D[i] * (S - D[i])

Ans = Ans // 2

print(Ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
nums = list(map(int, input().split()))
print(sum([i[0]*i[1] for i in list(itertools.combinations(nums, 2))]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
D = list(map(int, inputs[1].split()))

ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            break
        ans += D[i] * D[j]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

print(sum([ c[0]*c[1] 
    for c in list(itertools.combinations(D, 2))]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

from sys import stdin
n = int(stdin.readline().rstrip())
ds = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
all_combi = itertools.combinations(a_list, 2)
for i in all_combi:
    ans = 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):
  for j in range(N-1):
    if j >= i:
      pass
    else:
      ans += d[i] * d[j]

print(ans)

Submission status: Accepted

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

x = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))
sum = 0
for i in li:
  for j in li:
    sum += i * j

for i in li:
  sum -= i ** 2
sum //= 2
print(sum)

Submission status: Accepted

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

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(int(s/2))

Submission status: Accepted

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

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

print(m)

Submission status: Accepted

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

sum = 0
for x in range(n):
    for y in range(x+1, n):
        sum += D[x] * D[y]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

def solve(N: int, d: "List[int]"):
    l = list(itertools.combinations(d, 2))
    ans = 0
    for x,y in l:
        ans += x*y
    print(ans)
    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:
def main():
    n=int(input())
    d=list(map(int,input().split(' ')))
    ans = 0
    for n,i in enumerate(d):
        for m,j in enumerate(d):
            if n != m:
                ans += i*j
    print(ans//2)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
ans = []
for i in range(n):
    for j in range(n):
        if i < j:
            ans.append(d[i] * d[j])
print(sum(ans))

Submission status: Accepted

Solution code:
import itertools

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

a = [i for i in range(n)]
ans = 0

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

print(ans)

Submission status: Accepted

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

total = 0
for i in range(len(d_ls)):
    for k in range(i+1, len(d_ls)):
        total += d_ls[i] * d_ls[k]

print(total)

Submission status: Accepted

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

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

print(M)

Submission status: Accepted

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

def solve(N, d):
    total = 0
    for i1 in range(len(d)):
        for i2 in range(i1+1, len(d)):
            total += d[i1] * d[i2]
    return total


if __name__ == '__main__':
    N = int(input())
    d = map(int, input().split())

    ans = solve(N, list(d))

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

solve()

Submission status: Accepted

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

ans = 0
for i in range(len(dl)):
    for j in range(i+1,len(dl)):
        ans += dl[i]*dl[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(n) for n in input().split()]
ans = []
for i in range(N-1):
    for j in range(i+1, N):
        ans.append(d[i]*d[j])
print(sum(ans))

Submission status: Accepted

Solution code:
import itertools

N = int(input())
D = map(int, input().split())
s = 0
for d1, d2 in itertools.combinations(D, 2):
    s += d1 * d2
print(s)

Submission status: Accepted

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

print(count)

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