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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

final = 0

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

Submission status: Accepted

Solution code:
import sys
import itertools
N = int(input())
array = list(map(int,input().split()))

sum = 0
for I in list(itertools.combinations(array,2)):
    sum += I[0]*I[1]
print(sum)

Submission status: Accepted

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

S = sum(d)
T = sum(x*x for x in d)

print((S*S-T)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    d = list(map(int, input().split()))
    total = 0
    while len(d) > 1:
        c = d[0]
        for i in range(len(d) - 1):
            total = total + (c * d[1 + i])
        d.pop(0)
    print(total)
main()

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
S_1 = sum(D)
S_2 = sum([d**2 for d in D])
print((sum(D)**2-S_2)//2)

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
#１４３．2つの数字を選んで掛けてから足し合わせる
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=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:
ans=0
n=int(input())
li=list(map(int,input().split()))
for i in range(len(li)):
  for j in range(len(li)):
    if i==j:
      break
    ans+=li[i]*li[j]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in 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:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
d = intl()

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

Submission status: Accepted

Solution code:
input()
*l,=map(int,input().split())
ans=0
for i in l:
    for j in l:
        ans+=i*j
print((ans-sum([pow(x,2) for x in l]))//2)

Submission status: Accepted

Solution code:
input()
*l,=map(int,input().split())
ans=0
for i in l:
    for j in l:
        ans+=i*j
print((ans-sum([x*y for (x, y) in zip(l,l)]))//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(z)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans=0

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

print(ans)

Submission status: Accepted

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

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

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

dd = [di ** 2 for di in d]
print((sum(d) * sum(d) - sum(dd)) // 2)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = il()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
takoyaki = list(int(x) for x in input().split())

life = 0

for c in combinations(range(N), 2):
    life += takoyaki[c[0]] * takoyaki[c[1]]

print(life)

Submission status: Accepted

Solution code:
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

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

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
p = sum(A)
q = sum([a * a for a in A])
print((p*p-q)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [int(n) for n 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:
from itertools import *
N = int(input())
D = list(map(int,input().split()))
print(sum(x*y for x,y in combinations(D,2)))

Submission status: Accepted

Solution code:
import itertools
N = int(input())
Nlist = list(map(int, input().split()))
c = list(itertools.combinations(Nlist, 2))
ans = 0
for i in c:
    ans += i[0]*i[1]
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:
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

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()))
sum = 0
for i in range(n-1) :
    for k in range(i+1,n):
        sum += d[i]*d[k]
print(sum)

Submission status: Accepted

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

from itertools import combinations
counter = 0
for i in combinations(range(N),2):
    a,b = i
    counter += D[a]*D[b]
    

print(counter)

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()))
su = 0

for j  in range(N-1):
  for k in range(j+1, N):
    su += D[j] * D[k]
print(su)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int, input().split()))
ans=0
while len(d) > 1:
    tmp = d.pop(0)
    for i in d:
        ans += tmp * i
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

S = []
for i in range(N):
    for t in range(i):
        if i != t:
            S.append(d[i]*d[t])
print(sum(S))

Submission status: Accepted

Solution code:
from itertools import combinations

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

nc2 = list(combinations(d,2))
comb_sum = 0
for x,y in nc2:
  comb_sum += x * y
print(comb_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
data = list(map(int, input().split()))
sum = 0
for i in range(n):
    for j in range(i):
        if i == j:
            continue
        else:
            sum +=  data[i] * data[j]
            # print(sum)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

Submission status: Accepted

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

chofuku = 0
for x in d:
    for y in d:
        chofuku += x*y
chofuku //= 2

nochofuku = 0
for x in d:
    nochofuku += x*x
nochofuku //= 2

print(chofuku-nochofuku)

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



    print(int(ans/2))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

conbination = int((n * (n-1)) / 2)
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()))
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:
import itertools

N = int(input())
d_int_list = list(map(int, input().split()))
comb_list = list(itertools.combinations(d_int_list, 2))
ans = 0

for i in comb_list:
    ans += i[0] * i[1]

print(ans)

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

Submission status: Accepted

Solution code:
n,*d = map(int,open(0).read().split())
print(sum((sum(d)-i)*i for i in d)//2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, *d = map(int, open(0).read().split())
s = sum(d)
print(sum((s - i) * i for i in d)//2)

Submission status: Accepted

Solution code:
import itertools

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

d.sort(reverse=True)

result = []
for conb in itertools.combinations(d, 2):
  result.append(list(conb)) 
  
answer = 0
for i in result:
  answer += i[0]*i[1]

print(answer)

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

l1 = [x for x in range(n)]
l2 = [x for x in range(n)]

ans = 0
sub = 0

for v1, v2 in itertools.product(l1, l2):
    ans += D[v1] * D[v2]

for i in range(n):
    sub += D[i]*D[i]

print((ans-sub)//2)

Submission status: Accepted

Solution code:
import itertools


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

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = list(map(int,input().split()))
ans = 0
for v in itertools.combinations(d, 2):
  ans += v[0]*v[1]
print(ans)

Submission status: Accepted

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

ans = 0

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

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(range(n),2):
    ans += d[x] * d[y]
print(ans)

Submission status: Accepted

Solution code:
#<B>
from itertools import combinations
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in combinations(d,2):
    ans += i[0]*i[1]

print(ans)

Submission status: Accepted

Solution code:
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



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


		

if __name__ == "__main__":
	solve()

Submission status: Accepted

Solution code:
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



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


		

if __name__ == "__main__":
	solve()

Submission status: Accepted

Solution code:
from itertools import combinations

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

c=list(combinations(d,2))

ans=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
d = LI()

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()))
tmp = 0

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

print(tmp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    csum = accumulate(D)
    ans = sum(s * d for s, d in zip(csum, D[1:]))
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                ans += inlis[i] * inlis[j]
    print(ans)
    
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import itertools

N = int(input())
A = list(map(int, input().split()))
ans = []

for i in itertools.combinations(A,2):
    a,b = int(i[0]), int(i[1])
    s = a*b
    ans.append(s)

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt, sumd =0, sum(d)
for i in d:
    cnt += i * (sumd - i)
print(cnt // 2)

Submission status: Accepted

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

sumd = sum(d)
cnt = 0
for i in d:
    cnt += i * (sumd - i)
print(cnt // 2)

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

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

Submission status: Accepted

Solution code:
# 143 B

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 = sum +( d[i] * d[j])
        #print(pt)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
list=list(map(int, input().split()))
def pair(parameter):
        pairedList = []
        for iterater1 in range(len(parameter)):
                for iterater2 in range(iterater1+1,len(parameter)):
                        pairedList.append([parameter[iterater1],parameter[iterater2]])
        return pairedList

pairings = pair(list)
count=0
add=0
for i in pairings:
    x=i[0]*i[1]
    add+=x
print(add)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    d = list(map(int,input().split()))
    ans = 0
    for i in itertools.combinations(d, 2):
        ans += i[0] * i[1]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import accumulate as Z
n = input()
d = list(map(int,input().split()))
print(sum(a*b for a,b in zip(d[1:],Z(d))))

Submission status: Accepted

Solution code:
from itertools import accumulate
n = int(input())
d = list(map(int, input().split()))
print(sum(a*b for a, b in zip(d[1:], accumulate(d))))

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

print(ans)