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

Submission status: Accepted

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

ret = 0

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

print(ret)

Submission status: Accepted

Solution code:
n = int(input())

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

count = 0

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


print(count)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

s = 0
s2 = 0
for di in d:
	s += di
	s2 += di*di

ans = (s*s-s2)//2
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
buff = list(itertools.permutations(D, 2))

for e in buff:
    ans += e[0] * e[1]
# print(buff)

print(ans//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
d = list(map(int, input().split()))
s = sum([i[0] * i[1] for i in combinations(d, 2)])
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

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, 1):
        x = d[i] * d[j]
        res += x
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=input()
D=map(int, raw_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(D[i]*D[j])
print(ans)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = tuple(map(int, input().split()))
cnt = 0
for i in range(N):
    for j in range(0,i):
        cnt += S[i]*S[j]
        
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

c = 0
for i in range(len(t_list)):
  for j in range(len(t_list)):
    if (i == j):
      pass
    else:
      c += t_list[i] * t_list[j]
print(c // 2)

Submission status: Accepted

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

ans=0

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

Submission status: Accepted

Solution code:
import itertools

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

L = list(itertools.combinations(l,2))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
for x, y in list(itertools.combinations(D,2)):
    ans += x * y

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

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys


def readline():
    return sys.stdin.readline().rstrip()


def read(f=int):
    return f(readline())


def reads(f=int):
    return list(map(f, readline().split()))


def read_n(n: int, f=int):
    return [read(f) for _ in range(n)]


def reads_n(n: int, f=int):
    return [reads(f) for _ in range(n)]

N = read()
D = reads()

from itertools import combinations

print(sum(a * b for a, b in combinations(D, 2)))

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
  input()
  vals = list(map(int, input().split()))
  s = 0
  b = sum(vals)

  for v in vals[:-1]:
    b -= v
    s += v * b

  print(s)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import itertools

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

#Comb = list(itertools.combinations(D,2))
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 -*-
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

li = []
for i in range(n):
    for j in range(i, n):
        if i == j:
            continue
        li.append(d[i]*d[j])

print(sum(li))

Submission status: Accepted

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

Submission status: Accepted

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

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:
n = int(input())
d = list(map(int, input().split()))
count = 0
for i in range(n-1):
  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()))
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()))

t = 0

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

print(t)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(_) for _ in input().split()]

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

Submission status: Accepted

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

temp = list(itertools.combinations(d,2))
ans = 0
for t in temp:
    ans += t[0] * t[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 sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

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

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

print(ans)

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

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:
# from collections import defaultdict
# from heapq import heappush, heappop, heapify
# from bisect import bisect_left, insort_left
# from itertools import groupby


class Solution:
    def main(self):
        N = int(input())
        d = list(map(int, input().split()))

        print((sum(d)**2 - sum([d[i]**2 for i in range(len(d))]))//2)


if __name__ == '__main__':
    Solution().main()

Submission status: Accepted

Solution code:


N = int(input())

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

res = 0
for i_a in range(len(d)-1):
  for i_b in range(i_a+1,len(d)):
    #print(i_a,i_b)
    res += d[i_a]*d[i_b]
    
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, n):
        if i == j: continue
        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(N):
        if i == j:
            continue
        else:
            ans += d[i] * d[j]
print(ans//2)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

li=list(map(int,input().split()))
ans=0
for n in range(N):
  for k in range(n):
    ans+=li[n]*li[k]
print(ans)

Submission status: Accepted

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

N = len(D)
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())
d = list(map(int,input().split()))
ans1 = 0
ans2 = 0
for i in d:
    ans1 += i
    ans2 += i**2

print((ans1**2 - ans2)//2)

Submission status: Accepted

Solution code:
from itertools import combinations


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    d = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            ans += d[i]*d[j]
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

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:
n = int(input())

d = [int(i) for i in 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()))
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:
n = int(input())
d = list(map(int, input().split()))
ans = 0

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# B
import itertools

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

    ans = 0

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

    print(ans)

if __name__ == "__main__":
    main()

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

N=int(input())
D=list(map(int,input().split()))
_sum = 0
for _ in list(itertools.combinations(D,2)):
    _sum += _[0] * _[1]
print(_sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

from itertools import combinations
x = list(combinations(D, 2))

ans = 0
for a, b in x:
    ans += a * b
print(ans)

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

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
N = int(input())
D = list(map(int, input().split()))
res = 0
for comb in list(itertools.combinations(D, 2)):
    res += comb[0] * comb[1]
print(res)

Submission status: Accepted

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

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

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

# output
print(ans)

Submission status: Accepted

Solution code:
def solve():
  N = int(input())
  D = [int(i) for i in input().split()]
  s = sum(D)
  ans = 0
  for d in D:
    s -= d
    ans += s * d
  return ans

print(solve())

Submission status: Accepted

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

l=len(a)
ans=0
for i in range(l):
  for j in range(i+1,l):
    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-1):
    for j in range(i+1, N):
        sum += d[i]*d[j]

print(sum)

Submission status: Accepted

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

E = [d**2 for d in D]
print((sum(D)**2 - sum(E))//2)

Submission status: Accepted

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

def main():
    n = int(input())
    d = map(int, input().split())
    arr = list(itertools.combinations(d,2))
    ans = 0
    for x, y in arr:
        ans += x*y
    print(ans)



if __name__ == '__main__':
        main()

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(_) for _ 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())
ds = list(map(int, input().split()))

ans = 0
for i in range(N):
  for j in range(N):
    if j<=i:
      continue
    ans += ds[i]*ds[j]
print(ans)

Submission status: Accepted

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

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

print(output)

Submission status: Accepted

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

ans=0
for i in range(len(l)):
    for j in range(len(l)):
        if i==j:
            pass
        else:
            ans+=(l[i]*l[j])

print ans/2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = sum(l)
s1 = s*s
t = 0
for i in l:
    t += i*i
print((s1-t)//2)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for j in range(N):
    for i in range(N):
        if j == i:
            continue
        if j < i:
            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:
def f_b():
    n, *d = map(int, open(0).read().split())
    o = 0
    for i in range(n):
        for j in range(i+1, n):
            o += d[i]*d[j]
    print(o)

if __name__ == "__main__":
    f_b()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 0
stock = []
input()
for i in map(int, input().split()):
  for j in stock:
    ans += i * j
  stock.append(i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    n = ii()
    a = li()

    s = sum(a)

    ans = 0

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


main()

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

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

for i, j in combinations(range(n), 2):
  sum += d[i] * d[j]

print(sum)

Submission status: Accepted

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

ans = 0
for i,j in combinations(range(N), 2):
    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 itertools

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

ans = sum([x * y for x, y in itertools.combinations(d, 2)])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
D = [int(d) for d in input().split()]

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

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

import itertools as it
N=one_int()
ds=many_int()

temp = list(it.combinations(ds,2))
sums=0
for i in temp:
    sums+=(i[0]*i[1])

print(sums)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0

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


print(ans // 2)

Submission status: Accepted

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

Submission status: Accepted

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

a = 0
for i in range(n):
    a += d[i]**2
    
b = 0
for j in range(n):
    for k in range(n):
        b += d[j]*d[k]
        
ans = int((b-a)/2) 
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 = [int(i) for i in 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:
def solve():
    data = read()
    result = think(data)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)

def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    total = 0
    for i in range(n):
        for j in range(i + 1, n):
            total += data[i] * data[j]
    return total


def write(result):
    print(result)


if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    # import sys
    # sys.setrecursionlimit(10000)
    solve()

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

Submission status: Accepted

Solution code:
def read():
    N = int(input().strip())
    D = list(map(int, input().strip().split()))
    return N, D

def solve(N, D):
    s = 0
    for i in range(N):
        for j in range(i+1, N):
            s += (D[i] * D[j])
    return s

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))