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

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

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = int(readline())
    ds = map(int, readline().split())

    ans = 0
    for d1, d2 in itertools.combinations(ds, 2):
        ans += d1 * d2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

sum_ = 0
for i in range(n):
    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()))
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

def takoyaki_festival2019(n, dli):

    ans = 0
    itelist = list(itertools.combinations(range(n), 2))

    for i, k in itelist:
        ans += dli[i]*dli[k]

    return ans

def main():
    n = int(input())
    dli = list(map(int, input().split()))
    print(takoyaki_festival2019(n, dli))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans += d[i] * d[j]

    print(ans)


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

Submission status: Accepted

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

recover = 0

for i in range(n):
    for j in range(n):
        if i==j:
            pass
        else:
            recover += d[i]*d[j]

print(int(recover/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
d = list(map(int, input().split()))
l = []
count = 0
for i in range(0, len(d)):
  for j in range(0, len(d)):
    if i != j or d[i] != d[j]:
      a = sorted([d[i], d[j]], reverse=True)
      l.append(a)
for i in range(0, len(l)):
  count += l[i][0]*l[i][1]
print(math.floor(count/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()))
x=[]
for i in range(n-1):
  for j in range(i+1,n):
    x.append(d[i]*d[j])
    
print(sum(x))

Submission status: Accepted

Solution code:
N = int(input())
tako = list(map(int,input().split(" ")))
total = 0

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
aa=0
for i in a:
  x=i**2
  aa+=x
print(((sum(a)**2)-aa)//2)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

s = sum(d)
ans = 0

for i in d:
    ans += i*(s-i)
ans //= 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input().rstrip())
d  = [int(v) for v in input().rstrip().split()]
total = 0

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

print(total)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n=int(input())
d=list(map(int,input().split()))
lst=list(itertools.combinations(d,2))
ans=0
for i in range(len(lst)):
  ans+=lst[i][0]*lst[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:
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))

n = int(input())
D = ILI()
cnt=0
for i in range(n):
	for j in range(n-1-i):
		cnt += D[i]*D[j+i+1]
print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
D = rl()

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 os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

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

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

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

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


def f(N):
    return math.ceil(N / 10) * 10


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

    N = ii()
    D = il()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

def point(x,y):
  return x*y

sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum  += point(l[i],l[j])
    
print(sum)

Submission status: Accepted

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

print(sum(l))

Submission status: Accepted

Solution code:
n = int(input())
b = list(map(int,input().split()))
power = 0

for i in range(n):
    for j in range(i+1,n):
        power += b[i] * b[j]
print(power)

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)

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*n
a[:]=map(int,input().split())
r=0
for ii in range(n):
  for jj in range(n):
    if ii!=jj:
      r+=a[ii]*a[jj]
print(r//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0,N):
    for j in range(0,N):
        if not i == j:
            d = d + D[i]*D[j]
        if i == j:
            pass

print(d//2)

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

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

list_ = list(itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] * D[list_[i][1]];
  
print(count)

Submission status: Accepted

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=list(map(int,stdin.readline().split()))
suff=defaultdict(lambda:0)
ans=0
for i in range(n-1,-1,-1):
    ans+=a[i]
    suff[n-i]=ans 
ans=0
# print(suff)
for i in range(n-1):
    ans+=a[i]*suff[n-i-1]
print(ans)

Submission status: Accepted

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

sum = 0

xy = list(itertools.combinations(d, 2))
for i in range(len(xy)):
    sum += xy[i][0] * xy[i][1]

print(sum)

Submission status: Accepted

Solution code:
import itertools

N=int(input())
List = list(map(int, input().split()))
ans=0
    
 
for i in itertools.permutations(List, r=2):
    ans+=(i[0]*i[1])
    
    
print(int(ans/2))

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = list(map(int,input().split()))
c = list(itertools.combinations(d,2))

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

print(sum(c))

Submission status: Accepted

Solution code:
n = int(input())

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

ans=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

nC2 = list(combinations(d, 2))
add_hp = sum(
    [
        x * y
        for x, y in nC2
    ]
)

print(add_hp)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
import itertools
def main():
    N  = int(input())
    A = list(map(int, input().split())) 
    combilist = itertools.combinations(A,2)
    sum = 0
    for item in combilist:
        sum += item[0]*item[1]

    print(sum)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(n):
  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()))

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

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

num=itertools.combinations(a,2)

for i in list(num):
  ans+=i[0]*i[1]
  
print(ans)

Submission status: Accepted

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

for i in range(N):
    for j in range(i+1,N):
        life.append(d[i] * d[j])

print(sum(life))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
lst = list(map(int,input().split()))
ans = []
for v, k in itertools.combinations(lst, 2):
    ans.append(v*k)
print(sum(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()))
power = 0
for i in range(n-1):
    for j in range(i+1, n):
        power += d[i] * d[j]
print(power)

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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
import bisect


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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations

input()
values = tuple(map(int, input().split(' ')))
print(sum([x * y for x, y in combinations(values, 2)]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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(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
import numpy as np

def main():
    N = int(stdin.readline().rstrip())
    L = [int(x) for x in stdin.readline().rstrip().split()]
    C = list(itertools.combinations(L, 2))
    for i in range(len(C)):
        C[i] = np.prod(np.array(C[i]))
    C = sum(C)
    print(C)
    
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=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(sum//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
D = LI()

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

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

num = list(itertools.combinations(num, 2))

count = 0

for i in num:
  count += i[0] * i[1]

print(count)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

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

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

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

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


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

    N = ii()
    D = il()
    cum = itertools.accumulate(D)
    print(sum(c * d for c, d in zip(cum, D[1:])))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

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

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

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

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


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

    N = ii()
    D = il()
    ret = 0
    for i in itertools.combinations(D, 2):
        ret += i[0] * i[1]
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

x = len(t)

ans = 0

for i in range(x):
    for s in range(i+1,x):
        ans += t[i]*t[s]
        
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

from itertools import combinations


def solve():
    n = II()
    D = LI()

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
a=0
for i in L:
  a=a+i**2
b=sum(L)
print((b**2-a)//2)

Submission status: Accepted

Solution code:
# B - TAKOYAKI FESTIVAL 2019

N = int(input())
D = [int(d) for d 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()))

from itertools import combinations
comb = list(combinations(range(N), 2))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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


total = 0
for l in itertools.combinations(range(0, len(ds)), 2):
    total += ds[l[0]] * ds[l[1]]


print(total)

Submission status: Accepted

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

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())
D=[int(s) for s in input().split(" ")]

D.sort()

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

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

Submission status: Accepted

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

from itertools import combinations

c = combinations(Takoyaki,2)

total=0

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc143/tasks/abc143_b

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)