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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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:
import sys
input = sys.stdin.readline

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
Visit = [[False for j in range(N)]for i in range(N) ]
ans = 0

for i in range(N):
    for j in range(N):
        if i==j:
            continue
        if Visit[i][j] and Visit[j][i]:
            continue
        else:
            ans += d[i]*d[j]
            Visit[i][j] = True
            Visit[j][i] = True
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    N = int(input())
    D = [int(d) for d in input().split()]
    
    hp = 0
    for n in range(N):
        for m in range(N):
            if n >= m:
                continue
            hp += D[n] * D[m]
    print(hp)

main()

Submission status: Accepted

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

ans=0
for i in range(n-1):
  tako_1=a[i]
  for v in range(i+1,n):
    tako_2=a[v]
    tako=tako_1*tako_2
    ans+=tako

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

Submission status: Accepted

Solution code:
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
3 1 2"""
        output = """11"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """7
5 0 7 8 3 3 2"""
        output = """312"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

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:
            continue
        ans += D[i] * D[j]
print(int(ans / 2))

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

Submission status: Accepted

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

total = 0
i = 0
while i < N:
	j = i +1
	while j < N:
		total += D[i] * D[j]
		j += 1
	i += 1
	
print(total)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in 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 = [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:
'''B - TAKOYAKI FESTIVAL 2019
https://atcoder.jp/contests/abc143/tasks/abc143_b

>>> main(3, [3, 1, 2])
11
>>> main(7, [5, 0, 7, 8, 3, 3, 2])
312

'''

from itertools import combinations


def main(n, d):
    value = 0

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

    print(value)


if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split(' ')))

    main(n, d)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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


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


if __name__ == '__main__': main()

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for x, y in combinations(D, 2):
    ans += x * y

print(ans)

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

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

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(_) for _ in input().split()]
a = sum(d)
ans = a**2
for i in range(n):
  ans -= d[i] **2
print(ans//2)

Submission status: Accepted

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

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

Submission status: Accepted

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

takoyaki = 0
sum = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

s = sum(D)
sq = 0
for i in range(N):
    sq += D[i]**2
print((s**2 - sq)//2)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for x, y in combinations(d, 2):
    ans += x * y
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):
    #print(i,j)
    s+=D[i]*D[j]
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
l = map(int,raw_input().split())
val = list(l)
for i in xrange(n-2,-1,-1):
  l[i]+=l[i+1]
tot = 0
for i in xrange(n-1):
  tot+=((l[i]-val[i])*val[i])
print tot

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
d=LI()
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:
#abc143b

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

Submission status: Accepted

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

print(((sum(d)) ** 2 - sum([x ** 2 for x in d])) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

heal=0
total=sum(d)

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

print(heal)

Submission status: Accepted

Solution code:
def solve():
    N, *dl = map(int, open(0).read().split())
    ans = 0
    
    for i in range(N-1):
        for j in range(i+1, N):
            ans += dl[i] * dl[j]
    
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from copy import deepcopy

if __name__ == "__main__":
    num = int(input())
    base_list=[]
    tmp_list=[]
    ans=0
    base_list = input().split()
    tmp_list = deepcopy(base_list)
    for i in base_list:
        tmp_list.remove(i)
        for j in tmp_list:
            ans+=int(i)*int(j)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ds = [int(x) for x in input().split()]
ds2 = [x*x for x in ds]
s = 0
s2 = 0
for i in range(n):
  s += ds[i]
  s2 += ds2[i]
ss = 0
for i in range(n):
  ss += ds[i] * s

print((ss - s2) // 2)

Submission status: Accepted

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

sum_num = 0
for i, d1 in enumerate(D):
    for j, d2 in enumerate(D):
        if i < j:
            sum_num += d1*d2

print(sum_num)

Submission status: Accepted

Solution code:
n = int(input())
ds = [int(x) for x in input().split()]
ds2 = [x*x for x in ds]
s = sum(ds)
print(int((sum(ds * s) - sum(ds2)) / 2 ))

Submission status: Accepted

Solution code:
#import numpy as np
n = int(input())
#ds = np.array([int(x) for x in input().split()])
ds = [int(x) for x in input().split()]
ds2 = [x*x for x in ds]
#dss = ds * sum(ds)
#print((sum(ds * sum(ds)) - sum(ds ** 2)) / 2 )
print(int((sum(ds * sum(ds)) - sum(ds2)) / 2 ))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
sum_d = 0
sum_d2 = 0
for d in map(int,input().split()):
    sum_d += d
    sum_d2 += d * d
print((sum_d*sum_d - sum_d2)//2)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def answer_143b_2(): 
    n = int(input())
    dl = list(map(int,input().split()))

    ans = 0

    #[1,2,3,4,5]としたとき、iは一番左からチェックするとして、
    # iに対するjの組み合わせはi+1からリストの最後までの組み合わせが存在する。
    for i in range(n):
        for j in range(i + 1, n):
            ans += dl[i] * dl[j]

    print(ans)
    
if __name__ == '__main__':
    answer_143b_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())

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

sum = 0
count = 1

for d in dlist:
    for i in range(count,N):
        #print(dlist[i])
        sum = sum + dlist[i]*d
    count = count + 1 

print(sum)

Submission status: Accepted

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

total=0
for i in range(n):
    for j in range(n):
        total+=oisisa[i]*oisisa[j]

for i in range(n):
    total-=oisisa[i]*oisisa[i]
    
print(int(total/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(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())
lis = list(map(int,input().split()))
li = lis[:]

squ = [i**2 for i in lis]
sq = sum(squ)

a = []
for i in lis:
    for j in li:
        a.append(i*j)

print((sum(a)-sq)//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# B - TAKOYAKI FESTIVAL 2019
N = int(input())
D = list(map(int, input().split()))
s = sum(D)
square_s = sum([d ** 2 for d in D])
print((s ** 2 - square_s) // 2)

Submission status: Accepted

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

print(ans//2)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

N, *d = map(int, open(0).read().split())
print(sum(x * y for x, y in combinations(d, 2)))

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    s = sum(a)
    r = 0
    for c in a:
        r += c * (s-c)

    return r // 2


print(main())

Submission status: Accepted

Solution code:
def main():
# input
    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)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

class Solution(object):
    def __init__(self):
        self.n = int(sys.stdin.readline())
        a = sys.stdin.readline().split()
        self.d = [int(x) for x in a]

    def get_takoyaki_combo_sum(self):
        #option 1 Brute Force
        sum = 0
        for i in range(len(self.d)-1):
            for j in range(i+1, len(self.d)):
                sum += self.d[i] * self.d[j]
        return sum


if __name__ == "__main__":
    s = Solution()
    print(s.get_takoyaki_combo_sum())

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

print(sum)

Submission status: Accepted

Solution code:
import itertools
import numpy

n = int(input())
D = list(map(int, input().split()))
ans = 0

ls = itertools.combinations(D, 2)
for i in ls:
    ans += numpy.prod(i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations
from random import random

import numpy as np

sys.setrecursionlimit(200000)


class Solver:
    def __init__(self):
        pass

    def input(self):
        """
            faster input function than builtin stdin.
        """
        return sys.stdin.readline()[:-1]

    def ii(self, t: type = int):
        """
            input single value.
        """
        return t(self.input())

    def il(self, t: type = int):
        """
            input single line.
        """
        return list(map(t, self.input().split()))

    def imi(self, N: int, t: type = int):
        return [self.ii(t) for _ in range(N)]

    def iml(self, N: int, t: type = int):
        return [self.il(t) for _ in range(N)]

    def solve(self):
        N = self.ii()
        d = self.il()
        ans = 0
        for x, y in combinations(d, 2):
            ans += x * y
        return ans


if __name__ == "__main__":
    solver = Solver()
    print(solver.solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC143B - TAKOYAKI FESTIVAL 2019
def main():
    N, *D = map(int, open(0).read().split())
    ans = sum(x * y for i, x in enumerate(D) for y in D[i + 1 :])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

x = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(0, x-1):
    for j in range(i+1, x):
        ans = 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:
from itertools import combinations as com
n = int(input())
d = list(map(int,input().split()))
a = 0
for i in com(d,2):
  a += i[0] * i[1]
print(a)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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:
a = int(input())
l = list(map(int,input().split()))
s = 0
for e,i in enumerate(l):
    for j in l[e+1:]:
        s+=i*j
print(s)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
N = int(input())
L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

ans = 0
for i in range(N):
    for j in range(N):
        if i != j:
            ans += L[i] * L[j]
print(ans // 2)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        ans += d[i] * d[j]
print(ans//2)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())

ans = 0
n = int(input())
arr= lmi()
for i in range(n):
    for j in range(i+1, n):
        ans += arr[i]*arr[j]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N-1):
    a = d[i]
    b = sum(d[i+1:])

    s += a * b

print(s)