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()))
total = 0
for a in range(0,N-1,1):
  for b in range(a+1,N,1):
    total += d[a]*d[b]
print(total)

Submission status: Accepted

Solution code:
N = int(input())
de = list(input().split())

Ans = 0
for i in range(N):
    for j in range(N):
        if i != j:
            Ans += int(de[i]) * int(de[j])

print(int(Ans / 2))

Submission status: Accepted

Solution code:
n = int(input())
oisisa = list(map(int,input().split()))
oisisa_2 = []
for i in range(n):
    oisisa_2.append(oisisa[i] ** 2)
sum_2 = sum(oisisa_2)
count = 0
for i in range(n):
    for j in range(n):
        count += oisisa[i] * oisisa[j]
print(int((count - sum_2) / 2))

Submission status: Accepted

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

r = 0
for i in range(n - 1):
  r += d[i] * sum(d[i + 1:])
  
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
import itertools

def b():
    n = map(int, input())
    ds = list(map(int, input().split()))
    cs = list(itertools.combinations(ds, 2))

    sum_ = 0

    for c in cs:
        sum_ += c[0] * c[1]

    print(sum_)

if __name__ == '__main__':
    b()

Submission status: Accepted

Solution code:
n=int(input())
d=list(int(x) for x in input().split())

sum=0

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

Submission status: Accepted

Solution code:
n = int(input())
src = list(map(int, input().split()))
def calc_sum(tmp_list):
    score = 0
    while len(tmp_list)>1:
        tmp = tmp_list.pop(0)
        for l in tmp_list:
            score += tmp * l
    return score
print(calc_sum(src))

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
box = list(map(int, input().split()))
answer = []
for i in range(len(box)):
  ans = box[i] * sum(box[i+1:])
  answer.append(ans)
print(sum(answer))

Submission status: Accepted

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

D_2=sum([a**2 for a in D])

ans=0
for i,a in enumerate(D):
  for b in D[i:]:
    ans+=a*b
print(ans-D_2)

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
S=sum(D)
C=0
for i in D:
  C+=i*(S-i)
print(int(C/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()))
ret=0
for di in d:
  ret+=di*(sum(d))-di**2
print(ret//2)

Submission status: Accepted

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

from itertools import combinations

combi = list(combinations(ls, 2))

s = 0
for a, b in combi:
    s += (a * b)

print(s)

Submission status: Accepted

Solution code:
import itertools as it

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

total = 0
for x, y in it.combinations(d, 2):
    total += x * y

print(total)

Submission status: Accepted

Solution code:
from itertools import combinations

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:
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[N-1-j]
print(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

yum_combs = list(itertools.combinations(yums, 2))
sumyum = sum([x * y for x, y in yum_combs])

print(sumyum)

Submission status: Accepted

Solution code:
N = int(input())
d = input()
d_s = d.split(" ")
j = 0
ans = 0
for i in range(N):
    j = i + 1
    while j < N:
        ans = ans + int(d_s[i]) * int(d_s[j])
        j = 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]

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    A, B = LI()
    ans = A-2*B
    if ans > 0:
        print(ans)
    else:
        print(0)
    return

# B


def B():
    N = II()
    d = LI()
    ans = 0
    for i in range(N):
        for x in range(i+1, N):
            ans += d[i]*d[x]
    print(ans)

    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    # go = g
    # myset = set([1])
    sq = int(sqrt(g)) + 2
    ans = 1

    for i in range(2, sq):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g /= i

            # myset.add(i)
        if g == 1:
            break
        if i == sq - 1:
            # myset.add(go)
            ans += 1

    print(ans)

    return

# E


def E():
    N, M = LI()
    bit_max = 1 << N
    dp = [[inf for i in range(bit_max)] for j in range(M+1)]
    dp[0][0] = 0

    for i in range(M):
        a, b = LI()

        c = LI()
        bit = 0

        for d in c:
            bit |= 1 << (d-1)

        for w in range(bit_max):

            t = w | bit
            cost = dp[i][w] + a

            dp[i+1][t] = min(dp[i+1][t], cost)

            dp[i+1][w] = min(dp[i][w], dp[i+1][w])

    print(-1) if dp[-1][-1] == inf else print(dp[-1][-1])

    return

# F


def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")


def solution(S):
    # write your code in Python 3.6
    import math

    vowels = "AIUEO"
    count = 0
    consonants = 0
    newC = []
    newV = []

    for i in S[:-1]:
        if i in vowels:
            count += 1
            newV.append(i)
        else:
            consonants += 1
            newC.append(i)

    if consonants < count or consonants - 2 > count:
        return 0

    a = math.factorial(len(set(newC))) * math.factorial(len(set(newV)))
    return a

    pass


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations, starmap
from operator import mul

N = int(raw_input())
d = map(int, raw_input().split())
print sum(starmap(mul, combinations(d, 2)))

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
s=sum(l)
ss=s*s 
sq=sum(i*i for i in l)
print((ss-sq)//2)

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    result = 0
    for pair in itertools.combinations(d, 2):
        result += pair[0] * pair[1]
    print(result)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

#output
total = sum(d)

answer = 0
for i in range(N):
    answer += d[i]*(total-d[i])
answer = answer//2

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [int(d) for d in 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())
A = list(map(int, input().split()))
count = 0

for i in range(N):
  for j in range(N):
    if i != j and i < j:
      count += A[i]*A[j]
    
    
  
print(count)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

tmp = []
for i in range(len(Di)-1):
    for k in range(len(Di[i:])-1):
        tmp.append(Di[i] * Di[i+k+1])

print(sum(tmp))

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

total = 0
for i, l in enumerate(li):
  for j in range(i+1, n):
    total += l*li[j]

print(total)

Submission status: Accepted

Solution code:
num=int(input().rstrip())
numlis=input().rstrip().split(" ")


s=0
for i in range(num):
    for j in range(i+1,num):
        a=int(numlis[i])
        #print(a)
        b=int(numlis[j])
        #print(b)
        c=a*b
        #print(c)
        s+=c


print(s)

Submission status: Accepted

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

sum_ = 0
for i, x in enumerate(d):
  for j, y in enumerate(d):
    if i != j:
      sum_ += x * y

print(sum_//2)

Submission status: Accepted

Solution code:

from itertools import combinations

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

n = 0
for e in combinations(D, 2):
    n += e[0] * e[1]
print(n)

Submission status: Accepted

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

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

print(r)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(int(ans/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

s = 0
for item in list(combinations(d, 2)):
    s += item[0] * item[1]

print(s)

Submission status: Accepted

Solution code:
a = int(input())
input_list = list(map(int, input().split()))
sum = 0
for element in range(a):
    for element2 in range(a):
        if element >= element2:
            continue
        sum += input_list[element] * input_list[element2]
print(sum)

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 = sum + d[i]*d[j]


print(sum)

Submission status: Accepted

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

print(out)

Submission status: Accepted

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

sum = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        sum += D[i] * D[j]

print(int(sum/2))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
O = []
B = 0

for i in range(len(A)):
    for j in range(i+1, len(A)):
        C = A[i] * A[j]
        O.append(C)
for i in range(len(O)):
    B += O[i]
print(B)

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(sum)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
_ = int(input())
ds = list(map(int, input().split()))
sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8
n = int(input())
takoyaki_list = list(map(int,input().split()))
# strings = list(map(str, [input() for i in range(amount)]))
sum = 0

for i in range(len(takoyaki_list)-1):
    for j in range(i+1,len(takoyaki_list)):
        # print(str(i)+str(',')+str(j))
        sum += takoyaki_list[i]*takoyaki_list[j]
        
print(sum)

Submission status: Accepted

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

heal_value = 0
for i in range(len(d) - 1):
    heal_value += d[i] * sum(d[i + 1:])
print(heal_value)

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

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline())
d = [int(x) for x in stdin.readline().rstrip().split()]

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

print(tmp)

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

ans = 0
for i in range(n-1):
    ans += b[i] * sum(b[i+1:])

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

list_res = list(itertools.combinations(d,2))
result = 0
for x,y in list_res:
    result += x * y
print(result)

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

energy = 0
for i in range(N):
    tmp = D.pop(0)
    energy += tmp*sum(D)

print(energy)

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):
    deli = v[0]*v[1]
    ans += deli

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

conbi = list(itertools.combinations(D,2))

total = 0

for i in conbi:
	total += i[0] * i[1]

print(total)

Submission status: Accepted

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

A = sum(D)
ans = 0
for d in D:
    A -= d
    ans += A*d

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
di = list(map(int, input().split()))
sum_di = sum(di)
answer = 0
for d in di:
    answer += d * (sum_di - d)
print(answer // 2)

Submission status: Accepted

Solution code:
import itertools
 

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

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

Submission status: Accepted

Solution code:
N = int(input())
D = input().split()
for i in range(0, N):
  D[i] = int(D[i])
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:
import itertools
# x,y = map(int,input().split())

# s=list(input())
a=input()
a=int(a)

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

# s = [2, 3, 1, 4, 5]
# sorted(range(len(s)), key=lambda k: s[k])
max=0
for i in itertools.combinations(li,2):
    max+=i[0]*i[1]
print(max)

Submission status: Accepted

Solution code:
n = int(input())

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

result = 0

for i in range(n):
   tmp = d.pop(0)
   for j in d:
      result += j * tmp

print(str(result))

Submission status: Accepted

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

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

print(s//2)

Submission status: Accepted

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

#print(N)
#print(d_list)


total_cmb = int(N * (N-1) / 2)

total = 0
add_cnt = 0
for n1 in range(N):
    for n2 in range(N):
        if n1 < n2:
            total = total + d_list[n1] * d_list[n2]
            add_cnt = add_cnt + 1

#print(add_cnt, "/", total_cmb)
print(total)

Submission status: Accepted

Solution code:
from itertools import combinations

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

patterns = list(combinations(takoyakis,2))

sum = 0
for p in patterns:
  sum += p[0] * p[1]
  
print(sum)

Submission status: Accepted

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

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

sum_(N, D)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools


def main():
    _ = int(input())
    d = list(map(int, input().split()))

    comb = itertools.combinations(d, 2)

    ans = 0
    for v in comb:
        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
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(n):
        if(i is not j):
            ans += d[i] * d[j]

print(ans//2)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
l=list(map(int,input().split()))
ans=0
for item in list(itertools.combinations(range(N),2)):
  ans=ans+l[item[0]]*l[item[1]]

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i in range(0, n - 1):
        for j in range(i + 1, n):
            ans += d[i] * d[j]
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
num = int(input())
num_list = [int(item) for item in input().split()]

sum_heal = 0

for i, item_d1 in enumerate(num_list):
    for k, item_d2 in enumerate(num_list):
        if i > k:
            sum_heal += item_d1 * item_d2

print(sum_heal)

Submission status: Accepted

Solution code:

N = int(input())

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


if len(l) == 1:
    print(l)
else:
    sum = 0

    for i1 in range(len(l)):
        for i2 in range(i1+1, len(l)):
            sum += l[i1] * l[i2]

    print(sum)

Submission status: Accepted

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

print(r)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	n = int(input())
	d = list(map(int,input().split()))
	ans = 0
	for i in range(n):
		for j in range(n):
			if(j == i):
				continue
			ans += d[i] * d[j]
	print(ans//2)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
l=list(map(int,input().split()))

ans=sum(l)**2
for i in range(n):
    ans-=l[i]**2
ans=ans//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

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

N = int(input())

d = list(map( lambda x:int(x), input().split(" ") ))

sum_d = 0

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

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(d[i]*d[j])

print(s)

Submission status: Accepted

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

sum = 0

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

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

Submission status: Accepted

Solution code:
N=int(input())
L=[]
m=0
k=0

l=list(map(int,input().split()))
m=sum(l)
for i in range(N):
    k+=(m-l[i])*l[i]
ans=int(k/2)



print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
D = map(int, input().split())
result = 0
for x,y in itertools.combinations(D,2):
    result += x*y
print(result)