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:
#!/usr/bin/env python3
import itertools

N = int(input().split()[0])
d_list = list(map(int, input().split()))
p_gen = itertools.combinations(d_list, 2)
total = 0
for p in p_gen:
    a, b = p
    total += a * b
ans = total
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())
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 sys
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
d = IL()

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

Submission status: Accepted

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

ans=0

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

Submission status: Accepted

Solution code:
from sys import stdin
import itertools
N = int(stdin.readline().rstrip())
D = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in list(itertools.combinations(D,2)):
    ans += (i[0]*i[1])
print(ans)

Submission status: Accepted

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

import sys
from itertools import combinations

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = MAP()
A = LIST()

ans = 0
for a, b in combinations(A, 2):
    ans += a * b
print(ans)

Submission status: Accepted

Solution code:
import itertools
n,*d=map(int,open(0).read().split())
print(sum(a*b for a,b in itertools.combinations(d, 2)))

Submission status: Accepted

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

print(s)

Submission status: Accepted

Solution code:
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    D = [int(c) for c in input().split()]
    num = 0
    for i in range(len(D)):
        for j in range(i + 1, len(D)):
            num += D[i] * D[j]
    print(num)
    
            
        


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
N = I()
ans = int(0)
d = LI()

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

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 sys
import itertools

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()
sumv = 0
for i in itertools.combinations(D, 2):
    sumv += i[0] * i[1]
print(sumv)

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

print(res)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    D = string_to_int(inputs[0])
    sum_good = 0

    for i, d in enumerate(D):
        for j in range(i + 1, len(D)):
            sum_good += D[i] * D[j]
    return sum_good


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        ans += D[i] * D[j]

print(ans // 2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    ld = rli()
    ans = 0
    for i in range(len(ld)):
        for j in range(len(ld)):
            if j <= i:
                continue
            ans += ld[i]*ld[j]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d_s = list(map(int, input().split(' ')))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


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


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    d = LIST()

    ans =  0

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

    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import combinations as com
N = int(input())
ds = list(map(int, input().split()))
total = 0
for x, y in com(ds, 2):
    total += x*y
print(total)

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

sum_ = 0
for x, y in combinations(dlist, 2):
    sum_ += x * y

print(sum_)

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(res)

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for one in combinations(d,2):
    ans += one[0]*one[1]
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

d_sum = sum(d)
q_sum = 0
for i in range(n):
    q_sum += d[i]**2

print((d_sum**2-q_sum)//2)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(soma)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
from itertools import combinations
ans = 0
for a,b in combinations(D,2):
    ans += a *b
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    d = list(map(int, input().split()))
    res = 0
    for i, di in enumerate(d[:-1]):
        for j in d[i+1:]:
            res += di * j
    print(res)

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

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

def main():
    N = ii()
    d = lmis()
    print(sum(d[i]*d[j] for i in range(N) for j in range(i+1, N)))

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b=input()
a=list(map(int,input().split()))
s=sum(a)
an=0
for i in a:
    an+=(s-i)*i
print(an>>1)

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):
        if i == j:
            continue
        res += D[i] * D[j]

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l = [int(x) for x in input().split()]
l1 = list(combinations(l, 2))
c = 0
for i in l1:
	c += i[0]*i[1]
print(c)

Submission status: Accepted

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

result = 0
for a in range(N):
    for b in range(a+1, N):
        result += arr[a]*arr[b]

print(result)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Contest: AtCoder Beginner Contest 143 (https://atcoder.jp/contests/abc143)
# Problem: B

def rint():
    return int(input())


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


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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

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

Submission status: Accepted

Solution code:
import itertools

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ret = 0
total = sum(D)

for i in range(N):
	ret += D[i] * (total - D[i])
	
print(int(ret / 2))

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#import sys

#input = sys.stdin.readline



def main():
#    h,w,a,b = map(int, input().split())
    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)






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:
import sys


def main():
    n = int(sys.stdin.readline().strip())
    d = [int(s) for s in sys.stdin.readline().strip().split()]

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



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

Submission status: Accepted

Solution code:
input()
D=list(map(int,input().split()))
s=sum(D)
ss=sum(d**2 for d in D)
print((s**2-ss)//2)

Submission status: Accepted

Solution code:
def main():

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

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

print(dsum)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
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:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n = len(d)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

def solve():
    N = II()
    d_list = LI()

    from itertools import combinations

    sm = 0
    for comb in combinations(d_list, 2):
        sm += comb[0] * comb[1]

    print(sm)


solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sums)

Submission status: Accepted

Solution code:

import sys
#input = sys.stdin.readline
def solve():
  n = int(input())
  d = list(int(i) for i 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//2)
solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys; readline = sys.stdin.readline
from collections import deque


N = int(readline())
D = list(map(int, readline().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())
lst = list(map(int,input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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)

Submission status: Accepted

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

print((sum(a) ** 2 - sum((i ** 2 for i in a))) // 2)

Submission status: Accepted

Solution code:
N = int(input())
d_list = [int(x) for x in input().split()]
ans = 0
for i, di in enumerate(d_list):
    for dj in d_list[i+1:]:
        ans += di * dj
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(x)

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

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

output = 0

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

print(output)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
import itertools

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

c = list(itertools.combinations(d, 2))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(N):
  for j in range(N):
    if i != j:
      ans += d[i]*d[j]
print(int(ans/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())
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:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
d = list(map(int, input().split()))
dl = list(itertools.combinations(d, 2))
ans = 0
for a, b in dl:
  ans += a*b
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()

ans = 0
# print(list(combinations(range(N), 2)))
for i, j in list(combinations(range(N), 2)):
	ans += d[i] * d[j]
print(ans)

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

Submission status: Accepted

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

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

rtn = 0
for i in range(n):
    for k in range(n):
        if (i != k):
            rtn += d[i] * d [k]

rtn //= 2
print(rtn)

Submission status: Accepted

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


sum = 0
for i in range(n):
    for j in range(i):
        sum += dlist[i] * dlist[j]

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

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)