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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

while len(takoyaki) > 1:
    s = takoyaki.pop()
    for x in takoyaki:
        ans += s*x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

#print(d[2])

s = 0

for i in range(n):
	for j in range(n):
		if i == j:
			pass #ifで何もしない時は明示的にpassと書かないとエラーになる
		else:
			s = s + d[i]*d[j]
			
print(int(s/2))

Submission status: Accepted

Solution code:
N = int(input())
ds = input().split()
dsum = 0
for i in range(N):
  ds[i] = int(ds[i])
for i in range(N):
  for j in range(i):
    dsum += ds[i]*ds[j]
print(dsum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from itertools import combinations

def main():
    N = int(input())
    delicious = [int(s) for s in input().split()]
    combis = list(combinations(delicious, 2))
    heal = 0

    for combi in combis:
        heal += combi[0] * combi[1]
    print(heal)

if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

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

print(k)

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

Submission status: Accepted

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

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 print_ans(N,input_line):
    """Test Case
    >>> print_ans(3,"3 1 2")
    11
    >>> print_ans(7,"5 0 7 8 3 3 2")
    312
    """
    arr = list(map(int,input_line.split()))
    res = 0
    for i in range(N):
        for j in range(i+1,N):
            res += arr[i] * arr[j]
    print(str(res))
if __name__ == '__main__':
    N = int(input())
    input_line = input()
    print_ans(N,input_line)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
cb = list(itertools.combinations(list(map(int, input().split())), 2))
sm = 0
for c in cb:
    sm += c[0] * c[1]
print(sm)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(points)

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

Submission status: Accepted

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

dSum = sum(d) ** 2

for i in d:
    dSum -= i ** 2

print(dSum // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
ways = int(n * (n -1) / 2)

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

HP = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = input().split(" ")

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

print(sum)

Submission status: Accepted

Solution code:
n=int(input())
d=list(int(x) for x in input().split())
N=0#総和

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

print(str(N))

Submission status: Accepted

Solution code:
n = int(input().strip())
ds = list(map(lambda x: int(x.strip()), input().split()))

ans = 0

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

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(map(int, input().split()))
import itertools
import numpy as np
lis = list(itertools.combinations(d,2))
for i in range(len(lis)):
    lis[i] = np.prod(lis[i])
print(sum(lis))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
m=0
b=0 #n,l入力　m,b定義

for i in range(n):
   b=i
   for j in range((n-i)-1):
       b=b+1
       m=m+l[i]*l[b]

print(m)

Submission status: Accepted

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

store=[]

for i in range(N):
    if i < N:
        for j in range(i+1,N):
            store.append(l[i]*l[j])
print(sum(store))

Submission status: Accepted

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

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

print(ret)

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

for i in range(n-1):
  for j in range(n-i-1):
    e += s[i]*s[j+i+1]
print(e)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc143/tasks/abc143_b
# -*- coding: utf-8 -*-

tako_cnt = int(input())
tako_deli = list(map(int, input().strip().split()))

eat_hp = 0
for i in range(0,tako_cnt):
    for j in range(i + 1,tako_cnt):
        eat_hp += tako_deli[i] * tako_deli[j]

print(eat_hp)

Submission status: Accepted

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


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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    N = int(input())
    Ds = list(map(int, input().split()))

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import *

raw_input()
v = map(int, raw_input().split())
s = sum(x*y for x, y in combinations(v, 2))
print s

Submission status: Accepted

Solution code:
import math

N=int(input())
d=[0]*N
str=input().split(' ')
for i in range(0,N):
    d[i]=int(str[i])

result=0

for i in range(0,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()))

umaaji = 0

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

print(umaaji)

Submission status: Accepted

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

MOD = 10 ** 9 + 7

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np


def main():
    N = int(input())
    d = np.array([int(a) for a in input().split(" ")])
    s = np.sum(d)
    s2 = np.sum(d * d)
    print(int((s * s - s2) / 2))


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

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  d = list(map(int,input().split()))
  #print(d)
  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 = [int(i) for i in input().split()]
de = 0

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

print(de)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
D=[]*N
D=map(int,input().split(" "))
sum=0
for i,j in itertools.permutations(D,2):
    sum+=i*j

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

print(int(sum/2))

Submission status: Accepted

Solution code:
def takoyaki():
    amount = int(input())
    inStr = input().split()
    takoyakis = []
    sumEnergy = 0

    for i in range(amount):
       takoyakis.append(int(inStr[i]))

    for i in range(amount):
        for j in range(i + 1, amount):
            sumEnergy += takoyakis[i] * takoyakis[j]

    print(sumEnergy)

takoyaki()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc143/tasks/abc143_b
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(n-i-1):
    ans+=d[i]*d[j+i+1]

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
d = [int(x) for x in stdin.readline().rstrip().split()]
a = 0
for i in range(len(d)):
    for j in range(i):
        if i != j:
            a += d[i] * d[j]
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
input()
print(sum(x * y for x, y in combinations([int(i) for i in input().split()], 2)))

Submission status: Accepted

Solution code:
from itertools import combinations
input()
d = [int(i) for i in input().split()]
ans = 0
for x, y in combinations(d, 2):
  ans += x * y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for x in range(len(d)):
    for y in range(len(d)):
        if x != y :
            ans += d[x] * d[y]

print(int(ans / 2))

Submission status: Accepted

Solution code:
n=int(input())
d=input().split()
for i in range(n):
	d[i]=int(d[i])
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()))

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

Submission status: Accepted

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

print(s)

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+1,a):

    out=out+b[i]*b[j]
    
print(out)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N = input()
re = [int(x) for x in input().split()]
j = 0
s = len(re) - 1
for n in range(s):
	for m in reversed(range(s)):
		if m+1 == n:
			break
		j += re[n]*re[m+1]
print(j)

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

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

print(ans)

Submission status: Accepted

Solution code:
m=input()
A=int(m)
n=input()
t=n.split()
N=[]
sum=0
for i in range(0,A):
    N.append(int(t[i]))
for k in range(0,A):
    for l in range(k,A):
        if k!=l:
            sum=sum+N[k]*N[l]
print(sum)

Submission status: Accepted

Solution code:
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    dl = list(map(int, input().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__':
    main()

Submission status: Accepted

Solution code:
sum=0

n=int(input())
s=input().split()
t=[]
for i in range(n):
  t.append(int(s[i]))
#print(t)
for i in range(n):
  for j in range(n):
    if i==j:
        sum+=0
    else:
        sum+=t[i]*t[j]
print(int(sum/2))

Submission status: Accepted

Solution code:
n=input()
d=[int(i) for i in input().split()]
sum=0
while True:
  a=d[0]
  del d[0]
  if d == []:
    break
  for i in d:
    sum += a*i
print(sum)

Submission status: Accepted

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

from itertools import combinations
for i,j in combinations(range(N),2):
  ans += d[i-1]*d[j-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 j in range(i+1,n):
		ans += d[i]*d[j] if d[i]!=d[j] else d[i]**2
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = input().split()
b = [int(elem) for elem in b]
total = 0
for i in range(len(b)-1):
  for j in range(i+1, len(b)):
    total += b[i] * b[j]
print('{}'.format(total))

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 

input()
v = [int(i) for i in input().split(" ")]
combs = list(combinations(v, 2))
sums = [i[0] * i[1] for i in combs]
print(sum(sums))

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

Submission status: Accepted

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

ans = 0
for i in range(N-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()))
 
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:
import itertools
N = int(input())
x = list(map(int,input().split()))

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

Submission status: Accepted

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

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

souwa = 0

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

print(souwa)

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = sum([x * y for x, y in combinations(D, 2)])

print(ans)

Submission status: Accepted

Solution code:
N=int(input()) 
d=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

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

print(heal)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    D=lmis()
    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:
n = int(input())
d = [int(i) for i in 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 = [int(i) for i in input().split()]
s = n * (n-1)//2

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

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

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

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

print(ttl)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
count = 0
for x in d:
  for y in d:
    ans += (x * y)
ans_ = 0
for m in d:
  ans_ += m**2
print(int((ans-ans_)/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]
print(int(sum / 2))

Submission status: Accepted

Solution code:
import sys
import itertools


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    d = list(map(int, input().rstrip('\n').split()))
    t = 0
    for v in itertools.combinations(d, 2):
        t += (v[0] * v[1])
    print(t)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
data = [int(x) for x in input().split()]
data2 = [x**2 for x in data]

print((sum(data)**2 - sum(data2))//2)

Submission status: Accepted

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

s = 0
a = sum(d)
for i in d:
  s += i*(a - i)

print(int(s/2))

Submission status: Accepted

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

res = 0
cs = 0
for a in vA:
  res += cs * a
  cs += a
print(res)

Submission status: Accepted

Solution code:
import math
n = int(input())
d = list(map(int,input().split()))
li=[]
li2=[]
for i in range(n):
  for j in range(n):
    a = d[i]*d[j]
    li.append(a)
b = sum(li)
for k in range(n):
  c=d[k]**2
  li2.append(c)
d=sum(li2)
b -= d
print(math.floor(b/2))

Submission status: Accepted

Solution code:
N = int(input())
d = input().split(' ') #d = [d1, d2, d3...dN]
pattern = N * (N - 1) / 2
ans = []
for i in range(N):
	x = int(d[i])
	for j in range(N):
		y = int(d[j])
		if i > j:
			ans.append(x*y)
		else:
			pass
print(sum(ans))

Submission status: Accepted

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

i = 0
HP = 0
while i <= N-2:
	HP += d[0]*(sum(d)-d[0])
	del d[0]
	i+=1
    
print(HP)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(di) for di in 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(di) for di in 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_list = list(map(lambda x: int(x), input().split(" ")))

total = 0
for i in range(N-1):
    total += sum(list(map(lambda x: d_list[i]*x, d_list[i+1:])))

print(total)

Submission status: Accepted

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

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

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)