Problem:


Score : 200 points

Problem Statement

It's now the season of TAKOYAKI FESTIVAL!

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

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

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

Constraints

All values in input are integers.

2 \leq N \leq 50

0 \leq d_i \leq 100

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

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

Sample Input 1

3
3 1 2

Sample Output 1

11

There are three possible choices:

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

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

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

The sum of these values is 11.

Sample Input 2

7
5 0 7 8 3 3 2

Sample Output 2

312



Sample input:
3
3 1 2


Sample output:
11

Submission status: Accepted

Solution code:
import itertools

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

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

result = 0
for i in range(len(c)):
    result += c[i][0] * c[i][1]

print(result)

Submission status: Accepted

Solution code:
_,d=open(0)
a=b=0
for d in d.split():d=int(d);a+=d*d;b+=d
print(b*b-a>>1)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N,*D = map(int,read().split())

Dcum = itertools.accumulate(D) # 累積和
answer = sum(s*d for s,d in zip(Dcum,D[1:]))
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

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

sum = 0
for index, takoyaki1 in enumerate(d[:-1]):
    for takoyaki2 in d[index+1:]:
        sum += takoyaki1*takoyaki2

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

s = sum(d)

ans = s ** 2

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(e) for e in input().split()]
i = 0
j = 0
ans = 0
while(i < n):
    j = i + 1
    while(j < n):
        ans += d[i] * d[j]
        j += 1
    i += 1
print(ans)

Submission status: Accepted

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

val = 0
sum = 0

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

Submission status: Accepted

Solution code:
n = int(input())
stamina = 0
a = 1
delicious = [int(i) for i in input().split()]
for i in range(n):
  while i + a <= n-1:
    stamina += delicious[i] * delicious[i + a]
    a += 1
  a = 1
print(stamina)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

out = 0
for i in range(n):
  for j in range(n-i-1):
    out += L[i]*L[j+i+1]
print(out)

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]
        else:
            continue
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
s = 0
for i in range(n-1):
    for k in range(i+1,n):
        s+=a[i]*a[k]
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

suffix_sum = [0]*n
suffix_sum[-1] = a[-1]
res = 0
for i in range(n-2, -1, -1):
	res += a[i]*suffix_sum[i+1]
	suffix_sum[i] = suffix_sum[i+1] + a[i]
print(res)

Submission status: Accepted

Solution code:
_,d=open(0)
a=b=0
for d in d.split():d=int(d);a+=d*d;b+=d
print(b**2-a>>1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, *D = map(int, open(0).read().split())

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

print(ans)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
# coding: utf-8

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


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

print(energy)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
counter = 1
total = 0
for _ in range(N - 1):
  total += d[counter - 1] * sum(d[counter:])
  counter += 1
print(total)

Submission status: Accepted

Solution code:
# B - TAKOYAKI FESTIVAL 2019
n = (int)(input())

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

sum = 0

for i in range(n):
    for j in range(n):
        if i == j or i > j:
            continue
        else:
            sum += tako[i] * tako[j]

print(sum)

Submission status: Accepted

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

answer = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ln = input().split()
s = 0

for i in range(n):
  for j in range(i + 1, n):
    s += int(ln[i]) * int(ln[j])
    
print(s)

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:
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 = [int(d) for d in input().split()]
DD = []
S = [0] * n
for u in range(n):
	S[u] = D[u] ** 2
for s in range(n):
	for t in range(n):
		DD.append(D[s] * D[t])
for v in range(n):
	DD.remove(S[v])
print(int(sum(DD) / 2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split())) 
X = 0
for a in range(N):
    if a+1 < N:
        x = A[a]
        y = sum(A[(a+1):(N+1)])
        X += x*y

print(X)

Submission status: Accepted

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

answer=0

for i in range(N):
  for t in range(N):
    if t>i:
      answer+=d[i]*d[t]

print(answer)

Submission status: Accepted

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

for i in range(n):
  for j in range(n):
    if i>=j:
      continue
    hp=d[i]*d[j]
    HP+=hp
print(HP)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=raw_input()
DN=raw_input().split()

n = int(N)
dn = [int(i) for i in DN]

c = [dn[i]*dn[j] for i in range(n) for j in range(n) if i > j]

print reduce(lambda x,y: x+y, c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

total=0
for i_1 in range(n-1):
    for i_2 in range(n-i_1-1):
        total+=d[i_1]*d[i_1+i_2+1]
        
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
nums = [int(e) for e in input().split()]

rec=0
comb_list = list(itertools.combinations(nums,2))

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

print(rec)

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

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

sum=0

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

    
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(N-1):
    a = D.pop(0)
    for j in range(N):
        
        try:
            # print("a="+ srt(a)
            # print("D[j]=" +str(D[j]))
            ans += a * D[j]
        except:
            continue
        #ans += D[i] * D[i+1]


print(ans)

Submission status: Accepted

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

ans = 0

for i,di in enumerate(li):
    for j,dj in enumerate(li):
        if i <= j:
            continue
        ans += di*dj

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 sys

input = sys.stdin.readline

if __name__ == '__main__':
    N = int(input())
    d_list = list(map(int, input().split()))
    result = (sum(d_list) ** 2 - sum([d ** 2 for d in d_list])) // 2

    print(result)

Submission status: Accepted

Solution code:
import itertools

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

tako_list = [int(n) for n in range(1, int(tako)+1)]
hutatoori = list(itertools.combinations(tako_list, 2))

result = sum([oishisa[toori[0]-1]*oishisa[toori[1]-1] for toori in hutatoori])
print(result)

Submission status: Accepted

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

recover = []

c = 0
for i in d:
    c += 1
    recover.append(i * sum(d[c:N]))

print(sum(recover))

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

for i in range(len(d) - 1):
    next_index = i + 1
    for d2 in d[next_index:]:
        output += d[i] * d2
print(output)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import itertools


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

print(sum(map(lambda tup: tup[0] * tup[1], itertools.combinations(d, 2))))

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 19,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
lis = list(map(int, readline().split()))
s = sum(lis)
ans = 0
for i in lis:
    s -= i
    ans += s * i

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:
N = str(input())
Ds = str(input()).split(" ")
answer = 0
 
for di in range(len(Ds)):
  for dii in range(di+1,len(Ds)):
    sum = int(Ds[di]) * int(Ds[dii])
    answer += sum
print(answer)

Submission status: Accepted

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

cure = 0
for i in range(N):
  #print(i)
  for k in range(i, N-1):
    #print(i, k)
    cure = cure + takoyaki[i] * takoyaki[k+1]

print(cure)

Submission status: Accepted

Solution code:
# B: TAKOYAKI FES
N = int(input())
D = [int(d) for d in input().split()]
deli_list = [x*y for x in D for y in D]

# sum of diagonal 
self_comb = sum(D[i]*D[i] for i in range(N))

# (sum of 2D-Table - sum of diagonal) / 2
ans = int(((sum(deli_list)-self_comb)/2))
print(ans)

Submission status: Accepted

Solution code:
N = input()
d = input().split()
i_1 = 0
i_2 = 0
result = 0
for index_1 in d:
    i_1 += 1
    i_2 = 0
    if i_1 > int(N):
        print('a break')
        break
    for index_2 in d:
        i_2 += 1
        if i_2 > int(N):
            print('b break')
            break
        # print('A:' + index_1 + ' B:' + index_2)
        if i_1 < i_2:
            result += (int(index_1) * int(index_2))
            # print('result:' + str(result))

print(result)

Submission status: Accepted

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

# In[25]:


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


# In[27]:


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


# In[ ]:

Submission status: Accepted

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

recovery = 0
for i_d1 in range(N):
    for i_d2 in range(i_d1+1, N):
        recovery = recovery + d[i_d1]*d[i_d2]
print(recovery)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

for i in d:
    for j in d:
        S += i * j
for k in d:
    S -= k * k
print(S // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません

d = 0

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

Submission status: Accepted

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

point_sum = 0

for n in range(N):
    head = d.pop(0)
    point_sum += sum(list(map(lambda x : x * head, d)))
    
print(point_sum)

Submission status: Accepted

Solution code:
A=int(input())
B=input().split(' ')
B = [int(s) for s in B]

cnt = 0
dag = 0
for i in range(len(B)):
  dag +=B[i]*B[i]
  for j in range(len(B)):
    cnt += B[i]*B[j]

print(int((cnt-dag)/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, *d = map(int, open(0).read().split())
#print(N, d)

tako = []
for i in range(N):
    for j in range(i+1,N):
        #print(i,j, "(", d[i], d[j], ")")
        tako.append([d[i],d[j]])
#print(tako)
#print(len(tako))

sum = 0
for k in tako:
    sum += k[0]*k[1]
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split(" ")))
sum = 0
while len(d) >= 1:
    for i in range(1,len(d)):
        sum += d[0] * d[i]
    del d[0]
print(sum)

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 += (S-d[i])*d[i]
print(int(ans/2))

Submission status: Accepted

Solution code:
from itertools import combinations as C

N = int(input())
ds = [i for i in map(int, input().split())]

S = sum(a*b for a, b in C(ds, 2))
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    

print(ans//2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import itertools
import numpy as np

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

c = np.array([v for v in itertools.combinations(d, 2)])
print(sum(np.prod(c, axis=1)))

Submission status: Accepted

Solution code:
from itertools import combinations

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

comb = list(combinations(d, 2))

ans = 0

for i in range(len(comb)):
    ans += comb[i][0] * comb[i][1]
    # print(ans, comb[i])

print(ans)

Submission status: Accepted

Solution code:
num = int(input())
heellist = input().split(' ')

HeelSum = 0

for i in range(0, num):
  for j in range(i+1, num):
    HeelSum += int(heellist[i]) * int(heellist[j])

print(HeelSum)

Submission status: Accepted

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

total = []
for i1, d1 in enumerate(D):
    for i2, d2 in enumerate(D):
        if i2 > i1:
            total.append(d1 * d2)

print(sum(total))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = map(int, input().split())
b = list(map(int, input().split()))
c = []
while len(b)>0:
 k = b[0]
 b.pop(0)
 for s in b:
   c.append(k*s)
print(sum(c))

Submission status: Accepted

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

Submission status: Accepted

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

kaihuku =0

for i in range(n-1):
    #1つめのたこ焼きを選ぶ
    first = D.pop(0)
    #2つ目のたこ焼きを選ぶ
    for j in range(len(D)):
        kaihuku += first*D[j]
print(kaihuku)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def answer_143b(): 
    n = int(input())

    # mapでintに変換したものをさらにlist化する
    dl = list(map(int,input().split()))

    sum = 0

    for i in range(n):
        for j in range(n):
            if i == j :
                break
            sum = sum + (dl[i] * dl[j])
    print(sum)

if __name__ == '__main__':
    answer_143b()

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[j+i+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())
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:
import numpy as np

n=int(input())
d_list=list(map(int,input().split()))
d=np.array(d_list)
s=0

for i in range(n):
	for j in range(n):
		if j>i:
			s1=d[i]*d[j]
			s+=s1

print(s)

Submission status: Accepted

Solution code:
total = int(input())
tako_list = list(map(int, input().split()))
#print(tako_list)
total_rec = 0
for i in range(total):
    for k in range(1, total - i):
        recover = tako_list[i] * tako_list[i + k]
        total_rec += recover
print(total_rec)

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

Submission status: Accepted

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

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())
b=[]
d=[]
b=input().split()

for i in range(N):
    d.append(int(b[i]))

x=0
index=0
for i in range(N):
    x=d[0]
    d.remove(d[0])
    for k in range(N-1):
            index += x*d[k]
    N-=1

print(index)

Submission status: Accepted

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


res = 0

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

print(res)

Submission status: Accepted

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

d_sum = sum(d)

m = 0
for k in d:
    m += k **2
    
print((d_sum**2 - m)//2)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
#print(N)

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

c = itertools.combinations(d, 2)

E = []
for j in c:
    x, y = j
    E.append(x*y)

print(sum(E))

Submission status: Accepted

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

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

sum = 0

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

print(sum)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
tako = list(map(int,input().split()))
p = list(itertools.combinations(tako,2))
a = 0
for i in range(len(p)):
  a += p[i][0] * p[i][1]
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

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

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

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(i+1,n):
        s+=(l[i]*l[j])
print(s)

Submission status: Accepted

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

mount = 0

for i in range(len(tak) - 1):
	l = tak.pop(0)
	for k in tak:
		mount += l * k

print(mount)

Submission status: Accepted

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

pnt = 0
r = int((n * (n-1)) / 2)
cnt2 = 0

for i in range(r):
	cnt = i + 1
	cnt2 = 0
	for ii in range(n-cnt):
		cnt2 += 1
		pnt += ld[i] * ld[i+cnt2]
print(pnt)

Submission status: Accepted

Solution code:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
d = LIST()
res = 0
for i in range(n-1):
    for j in range(i+1,n):
        if i != j:
            res += d[i] * d[j]

print(res)

Submission status: Accepted

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

Submission status: Accepted

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