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:

def main():
    N = int(input())
    K = [int(x) for x in input().split()]
    ans = 0
    for n in range(0, N):
        for k in range(n+1, N):
            ans += K[n] * K[k]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
takoyaki_len = int(input())
takoyaki_good = input().split()
recovery = 0

i = 0
while (i < takoyaki_len):
    j = i+1
    while (j < takoyaki_len):
        recovery += int(takoyaki_good[i]) * int(takoyaki_good[j])
        j += 1
    i += 1

print(recovery)

Submission status: Accepted

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

a = 0

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

print(a)

Submission status: Accepted

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

a = []

for i1 in range(n):
    for i2 in range(n):
        if i1 != i2:
            a.append(d[i1] * d[i2])

print(int(sum(a) / 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:
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 = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

Solution code:
while True:
    n = input()
    s = input().split()
    n = int(n)
    s = list(map(int,s))
#for i in s:
 #       s[i]=int(s[i])
    if n==len(s):
        break
x=0
for i in range(0,n):
    for j in range(i+1,n):
        x+=s[i]*s[j]

print(x)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC143-B 累積和でやってみる
N = int(input())
d = list(map(int, input().split()))
acd = []
sumd = 0
for i in range(N):
    sumd += d[i]
    acd.append(sumd)
ans = 0
for i in range(N):
    ans += d[i] * (acd[N-1] - acd[i])
print(ans)

Submission status: Accepted

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

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:
#ABC143-B TAKOYAKI FESTIVAL 2019
N = int(input())
d = list(map(int, input().split()))
ans = (sum(d)**2 -sum([x*x for x in d]))//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(sum)

def main():
    ABC143B_TakoyakiFes()

if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print(max(0, a - 2 * b))
    return

#B
def B():
    n = II()
    d = LI()
    ans = 0
    for i in range(n):
        for k in range(i+1, n):
            ans += d[i] * d[k]
    print(ans)
    return

#C
def C():
    n = II()
    s = S()
    i = 0
    ans = 1
    for i in range(1, n):
        if s[i - 1] == s[i]:
            continue
        ans += 1
    print(ans)
    return

#D
def D():
    n = II()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n - 1, 0, -1):
        for k in range(i - 1, -1, -1):
            ab = l[i] - l[k]
            c = max(0, k - bisect_right(l, ab))
            ans += c
    print(ans)
    return

#E
def E():
    n, m, l = LI()
    dist = [[inf] * n for i in range(n)]

    for _ in range(m):
        a, b, c = LI_()
        c += 1
        if c > l:
            continue
        dist[a][b] = c
        dist[b][a] = c

    supply = [[n] * n for i in range(n)]
    for k in range(n):
        distk = dist[k]
        for i in range(n):
            if i == k:
                continue
            disti = dist[i]
            distik = dist[i][k]
            for j in range(i + 1, n):
                if distik + distk[j] < disti[j]:
                    disti[j] = distik + distk[j]
                    dist[j][i] = disti[j]

    lis = [[] for i in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if dist[i][j] <= l:
                supply[i][j] = 0
                supply[j][i] = 0
                lis[i].append(j)
                lis[j].append(i)

    for i in range(n):
        q = []
        for k in lis[i]:
            heappush(q, (0, k))
        supplyi = supply[i]

        while q:
            time, p = heappop(q)
            for k in lis[p]:
                if supplyi[k] > time + 1:
                    supplyi[k] = time + 1
                    heappush(q, (time + 1, k))

    q = II()
    for _ in range(q):
        s, t = LI_()
        if dist[s][t] == inf:
            print(-1)
            continue
        else:
            print(supply[s][t])
    return


#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

for i in range(len(d)):
    for j in range(i,len(d)):
        if i != j:
            s+= d[i]*d[j]

print(s)

Submission status: Accepted

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

combination = list(combinations(D,2))
total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(ds) -> int:
  ret = 0
  for i in range(len(ds)):
    for j in range(i + 1, len(ds)):
      ds_i = ds[i]
      ds_j = ds[j]
      ret += ds_i * ds_j
  return ret


n = int(input().strip())
ds = [int(d) for d in input().split()]

print(solve(ds))

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
a = list(map(int,input().split()))
t=0
for i in itertools.combinations(a, r=2):
    t+=i[0]*i[1]

print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces


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

Submission status: Accepted

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

s = sum(l)
c = 0
for i in l:
  c += (s-i)*i
  
print(c//2)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
*d, = map(int, input().split())

ans = 0
for c in itertools.combinations(d, 2):
    ans += c[0]*c[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 l in range(i+1 ,N):
        sum += d[i]*d[l]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if i != j:
            ans += int(d[i])*int(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 k in range(n):
        if i != k:
            ans += d[i] * d[k]

print(ans//2)

Submission status: Accepted

Solution code:
import sys

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

HP=0
for i in range(N):
  for j in range(N):
    if i!=j:
      HP1=x[i]*x[j]
      HP=HP+HP1

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

Submission status: Accepted

Solution code:
N = int(input())

d = list(map(int, input().split()))
e = []
for i in range(len(d) - 1):
    e.append(d[i] * sum(d[(i + 1):]))

print(sum(e))

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

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

def HP(tako1, tako2):
    return tako1*tako2

total_HP = 0
tako_combos = combinations(d, 2)
for takos in tako_combos:
    tako1 = takos[0]
    tako2 = takos[1]

    total_HP += HP(tako1, tako2)

print(total_HP)

Submission status: Accepted

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

import math
import itertools

t = input()
l = input().split()
total = 0


for i in itertools.combinations(l, 2):
    total += int(i[0]) * int(i[1])

print(total)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
l = len(a)

sum = 0

for j in range(0, n):
    for i in range(1, l):
        m = int(a[0]) * int(a[i])
        sum += m
    del a[0]
    l = len(a)

print (sum)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
list =   [int(x) for x in input().split()]
sum = 0
for i in range(n):
    for j in range(n-1):
        if i + j + 1 >= n:
            continue
        sum += list[i] * list[i+j+1]
print(sum)

Submission status: Accepted

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

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split(' ')))
s=0
s2=0
for x in d:
	s+=x
	s2+=x*x
print((s*s-s2)//2)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d_list = input().split()

r = 2
ncr_list = list(itertools.combinations(d_list, r))

hp = 0
for ncr in ncr_list:
	hp += int(ncr[0]) * int(ncr[1])
	
print(hp)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(total)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
d = np.array(input().split()).astype(int)
a = np.outer(d,d)
np.fill_diagonal(a, 0)
a = np.triu(a)
print(a.sum())

Submission status: Accepted

Solution code:
#coding:utf-8
import itertools

# 入力
N = int(input())
TAKOYAKIS = [int(i) for i in input().split()]

combinations = list(itertools.combinations(TAKOYAKIS, 2))

healing_value = []
for c in combinations:
    healing_value.append(c[0] * c[1])
    

print(sum(healing_value))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

class TakoyakiFestival:
    def __init__(self):
        self.N = int(input())
        self.T = list(map(int,input().split(' ')))
  #      print(self.T)
        self.souwa = 0

    def solve(self):
        takokumi = list(itertools.combinations(self.T, 2))
        for i1, i2 in takokumi:
            self.souwa += (i1 * i2)
        return self.souwa

tako = TakoyakiFestival()
ans = tako.solve()

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

tmp = 0

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools as it

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

l = it.permutations(d, 2)

temp = 0

for i in l:
    temp += i[0] * i[1]

print(temp // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import*;input();print(sum([n*m for n,m in combinations(map(int,input().split()),2)]))

Submission status: Accepted

Solution code:
import itertools

N = int(input())
takoyakis = map(int, input().split())
s = 0

for n1,n2 in itertools.combinations(takoyakis, 2):
  s += n1*n2
  
print(s)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

in_N = [int(i) for i in input().split()];
in_d = [int(i) for i in input().split()];

#print(in_N);
#print(in_d);

#calc
total = 0;
for i in range(in_N[0]):
    for j in range(len(in_d)-1):
        #print(i);
        #print(j);
        if(i+j+1 == len(in_d)):break;
        total += in_d[i]*in_d[i+j+1];

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np 

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

print((d.sum()**2 - (d**2).sum()) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r = lambda : map(int, input().split(' '))

n = int(input())
a = list(r())
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()))
sums=0
for i in range(n):
  for j in range(i,n):
    if i!=j:sums+=d[i]*d[j]
print(sums)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''n,k = input().split()
n = int(n)
k = int(k)
'''

n = int(input())
m = list(map(int,input().split()))
out = 0
for i in range(n):
    for j in range(i):
       out += m[i]*m[j]

print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
d = [int(i) for i in input().split()]
sum = 0
for i in range(1,n):
    for j in range(i+1,n+1):
        add = d[i-1] * d[j-1]
        sum += add
print(sum)

Submission status: Accepted

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


import itertools
ans = 0
for a,b in list(itertools.combinations(d,2)):
    ans += a * b
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a=int(input())
b=list(map(int,input().split()))
out=0
for i in range(a):
  for j in range(i,a):
    if i==j:
      continue
    else:
      out=out+b[i]*b[j]

print(out)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(i) for i in input().split()]
dsum=0
for i in range(n):
  for j in range(n):
    dsum+=d[i]*d[j]
  dsum-=d[i]*d[i]
print(dsum//2)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
d1 = [i**2 for i in d]
s = sum(d)
ans = (s**2 - sum(d1))//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
li = list(map(int, input().split()))
com_li = list(itertools.combinations(li, 2))
result_li= []

for i in com_li:
  count = i[0] * i[1]
  result_li.append(count)

result = sum(result_li)
print(result)

Submission status: Accepted

Solution code:
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 = 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())
t = [int(x) for x in input().split()]
t2 = [x * x for x in t]
print((sum(t) ** 2 - sum(t2))//2)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
D = list(map(int, input().split()))
Sum = 0
for p in itertools.combinations(D, 2):
    Sum += p[0]*p[1]
print(Sum)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

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

Submission status: Accepted

Solution code:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

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

print(ans)

Submission status: Accepted

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

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())
list = list(map(int,input().split()))
sum = 0
for i in range(len(list)):
	for j in range(i+1,len(list)):
		sum +=list[i]*list[j]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    return


def main():
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

total = sum([A[i] * A[j] for i in range(0, N) for j in range(i + 1, N)])

print(total)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d2 = list(map(lambda x: x * x, d))
print((sum(d) ** 2 - sum(d2)) // 2)

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(c)

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):
        # print("{0}×{1}".format(d[i], d[j+i+1]))
        sum += d[i]*(d[j+i+1])

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(buf)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(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:
# 2019-11-19 10:28:31(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, *d = map(int, sys.stdin.read().split())

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


if __name__ == "__main__":
    main()