Problem:


Score : 200 points

Problem Statement

It's now the season of TAKOYAKI FESTIVAL!

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

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

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

Constraints

All values in input are integers.

2 \leq N \leq 50

0 \leq d_i \leq 100

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

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

Sample Input 1

3
3 1 2

Sample Output 1

11

There are three possible choices:

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

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

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

The sum of these values is 11.

Sample Input 2

7
5 0 7 8 3 3 2

Sample Output 2

312



Sample input:
3
3 1 2


Sample output:
11

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i1 in range(N - 1):
  for i2 in range(i1 + 1, N):
    ans += ds[i1] * ds[i2]

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
Y=[int(i) for i in input().split()]

result=0
for i in range(1, X):
  for j in range(X):
    if i+j<=X-1:
      result+=Y[j]*Y[j+i]
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0

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

Submission status: Accepted

Solution code:
import itertools,functools
N=int(input())
XY=list(map(int,input().split()))
A=list(itertools.combinations(XY, 2))
ANS=functools.reduce(lambda a,b: a+(b[0]*b[1]), A, 0)
print(ANS)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
ans = 0
from itertools import combinations
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
combi_list = list(combinations(L,2))
for i in combi_list:
    ans += i[0] * i[1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = [int(i) for i in input().split()]
ans = 0
for i in range(a):
  ans += b[i]*(sum(b)-b[i])
print(ans//2)

Submission status: Accepted

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

print(sum(list(map(lambda x:(s-x)*x, d)))//2)

Submission status: Accepted

Solution code:
import itertools

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

comb_list = list(itertools.combinations(D,2))

res = 0
for comb in comb_list:
    res += comb[0] * comb[1]

print(res)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  sm=0
  for i,x in enumerate(l):
    for j,y in enumerate(l[i+1:]):
      sm+=x*y
  return sm

# main()
print(main())

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

sumn = 0

for i in d:
	for j in d:
		sumn += i*j
	sumn -= i*i

print(sumn//2)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
length = input()
rtn = 0
li = list(map(int, input().split()))
for i, n1 in enumerate(li):
    if len(li) == i + 1:
        print(rtn)
        break
    for j, n2 in enumerate(li):
        if i >= j: continue
        rtn += n1 * li[j]

Submission status: Accepted

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

res = 0
for i in range(N):
  for j in range(i, N):
    if i != j:
    	res += L[i] * L[j]
        
print(res)

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

Submission status: Accepted

Solution code:
import itertools as itl

N=int(input())
d_i=(int(x) for x in input().split())
c_list=list(itl.combinations(d_i,2))

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

print(sum)

Submission status: Accepted

Solution code:
N = int(raw_input())
A = map(int, raw_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()))

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

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
d = list(map(int, input().split()))

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:
import itertools
N = int(input())
a = itertools.combinations(list(map(int,input().split())),2)
print(sum([i*j for i,j in a]))

Submission status: Accepted

Solution code:
N=int(input())
D=[int(_) for _ in input().split()]
sum=0
j=1
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(' ')]
t = 0

for i in range(N):
  for j in range(N):
    if i<j:
      t += d[i]*d[j]  
print(t)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
nums = list(map(int,input().split()))
count = 0

for c in list(itertools.combinations(nums,2)):
    count += c[0] * c[1]

print(count)

Submission status: Accepted

Solution code:
gomi=input()
tako=[int(i) for i in input().split()]
print(int((sum(tako)**2-sum([i**2 for i in tako]))/2))

Submission status: Accepted

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

sum = 0
for i in range(N):
    for j in range(N):
        if j <= i:
            continue
        sum += int(d[i]) * int(d[j])
        # print(sum)

print(sum)

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

sn = 0

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

Submission status: Accepted

Solution code:
number_tako= int(input())
tako_taste= list(map(int,input().split()))
sum_taste=0

for index_first,taste_1 in enumerate(tako_taste):
	for index_second,taste_2 in enumerate(tako_taste):
		if index_first < index_second:
			sum_taste=sum_taste+taste_1*taste_2

print(sum_taste)

Submission status: Accepted

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

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

print(an)

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:
            continue
        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:
# coding: utf-8

n = int(input())
takoyaki = [int(s) for s in input().split()]

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

print(tairyoku)

Submission status: Accepted

Solution code:
# ABC143 B - TAKOYAKI FESTIVAL 2019

N = int(input())

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

sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for fst in range(N-1):
  for snd in range(fst + 1,N):
    sum = sum + d[fst] * d[snd]
    
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
lst = list(map(int, input().split()))
ret = 0
for idx, x in enumerate(lst[:-1]):
    for y in lst[idx + 1:]:
        ret += x * y
print(ret)

Submission status: Accepted

Solution code:
    
N=int(input())

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

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

Submission status: Accepted

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

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

ans = 0 

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
strList = input().split(" ")
dList = [int(s) for s in strList]

cmb = list(itertools.combinations(dList, 2))
res = 0
for d1, d2 in cmb:
    res += d1 * d2

print(res)

Submission status: Accepted

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

left = sum(d_list)
ans = 0
for d in d_list:
    left-=d
    ans+=d*left
print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = list(map(int,input().split()))
a=[]
a=list(itertools.combinations(d,2))
x=0
for i in range(len(a)):
  x+=a[i][0]*a[i][1]
  
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

# Input
s = [input() for i in range(2)]

N = int(s[0])
D = list(map(int, s[1].split()))


# Process
H = 0
for i in range(0,N):
    for j in range(1,N):
        H += D[i-j]*D[i]

H = int(H/2)


# Output
print(H)

Submission status: Accepted

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

Submission status: Accepted

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

accum = [0 for _ in range(N)]

for i, _d in enumerate(d):
  if i == 0:
    accum[i] = _d
  else:
    accum[i] = accum[i-1] + _d

res = 0
for i, _d in enumerate(d):
  if i < N-1:
    res += d[N-i-1] * accum[N-i-2]
  
print(res)

Submission status: Accepted

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



N = int(input())
Dn = list(map(int, input().split()))
ret = 0
for d1 in range(N):
  for d2 in range(d1+1,N):
    ret += Dn[d1] * Dn[d2]
print(ret)

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

Submission status: Accepted

Solution code:
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy
#import heapq
#import math
#import string

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in 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(n):
        if i != j:
            ans += d[i] * d[j]
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, d):
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            res += d[i] * d[j]
    return res

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
ans = 0
for i in range(N):
    d = D.pop(0)
    ans += d * sum(D)

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

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
d = readl()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

print(summary)

Submission status: Accepted

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

Submission status: Accepted

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

f = sum(d)
s = 0

for i in d:
  s += i * (f-i)
print(s//2)

Submission status: Accepted

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

Submission status: Accepted

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

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:
x = input()
y = input().split()

response = 0

for i in range(int(x)):
  for l in range(i+1,int(x)):
    num = int(y[i]) * int(y[l])
    response += num
    
print(response)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
#print(N, d)
sum = 0
for i_idx, i in enumerate(d):
  for j_idx, j in enumerate(d):
    if(i_idx!=j_idx):
      sum+=i*j
print(int(sum/2))

Submission status: Accepted

Solution code:
from itertools import combinations


def main():
    n = int(input())
    ds = map(int, input().split())

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
sum = 0
i = 0
while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += d[i] * d[k]
  i += 1
print(sum)

Submission status: Accepted

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

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += d[i] * d[k]
  i += 1
  
print(sum)

Submission status: Accepted

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

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
arr = [int(x) for x in input().split()]
f = sum(arr)
s = 0
for i in arr:
  s += i * (f-i)

print(s // 2)

Submission status: Accepted

Solution code:
n=input()
D=list(map(int, input().split()))
total=0
while len(D)>0:
    tmp=D.pop()
    for i in range(len(D)):
        total = total + tmp*D[i]
print(total)

Submission status: Accepted

Solution code:
from sys import stdin

N = int(input())
d = list(map(int,stdin.readline().strip().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:
sumtaste = 0

n = int(input())
takoyakis = [int(i) for i in input().split()]

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

print(sumtaste)

Submission status: Accepted

Solution code:
import itertools

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

print(sum(x * y for x, y in itertools.combinations(li_d, 2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,*d = map(int, open(0).read().split())
total = 0
for i in range(n):
    total += d[i]

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def fin(f):
    return f(input())


def gin(f, number=1):
    for _ in range(number):
        yield list(map(f, stdin.readline().split()))


def lin(f):
    return next(gin(f))


n = fin(int)

ans = 0
D = lin(int)
for i, d in enumerate(D):
    for e in D[i+1:]:
        ans += d*e

print(ans)

Submission status: Accepted

Solution code:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
D = [int(_) for _ in stdin.readline().rstrip().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 numpy as np

n = int(input())

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
D_cal = [D[i]*D[j] for i in range(N) for j in range(N) if i != j]
#print(D_cal)
print(sum(D_cal)//2)

Submission status: Accepted

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int, input().split()))
ans=0
k=0
h=1
while k<=n-1:
  for i in range(n-h):
    ans+=l[k]*l[i+h]
  k+=1
  h+=1
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, n):
        if i==j:
            continue
        tmp = d[i]*d[j]
        ans += tmp
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,1):
    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(N):
        if(i!=j):ans += a[i]*a[j]
print(int(ans/2))

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())
T=[int(i) for i in input().split()]

ans=0
for i in range(n):
    for q in range(n-i-1):
         ans+=T[i]*T[i+q+1]   
         
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(range(N), 2):
    ans += D[i-1] * D[j-1]
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

def main():
    n=int(input())
    d=inputList()

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

    print(ans)

def inputList():
    a=list(map(int,input().split()))
    return a

def multisort(li,index):
    return sorted(li,key=lambda x: x[index])

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

Submission status: Accepted

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

all = 0
for i1, d1 in enumerate(dlist):
  for d2 in dlist[i1+1:]:
    all += d1*d2

print(all)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(s)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
ans = 0
for i, x in enumerate(D):
  for j, y in enumerate(D):
    if(i >= j):continue
    ans += x*y
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
ans = 0
for i, x in enumerate(D):
    for j, y in enumerate(D):
        if(i>=j):continue
        ans += x*y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
j = 0
count = 0
i = 1
while j < n:
    if j + i < n:
        count += d[j] * d[j + i]
        i += 1
    else:
        j += 1
        i = 1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

su = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
D=tuple(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(0, N - 1):
    for j in range(i + 1, N):
        ans = 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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


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

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for x in range(n):
    for y in range(x+1, n):
        ans += d[x] * d[y]

print(ans)

Submission status: Accepted

Solution code:
import itertools

N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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