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

res = 0
for i in range(N):
    res += sum(D[i + 1:])*D[i]
print(res)

Submission status: Accepted

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

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

print((sum(d)**2-d2_sum)//2)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(i) for i in input().split()]
ans=chk=0
for i in range(n):
    for j in range(n):
        if i!=j:
            ans+=d[i]*d[j]
print(ans//2)

Submission status: Accepted

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

ans = 0
for e in c:
    ans += e[0]*e[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()))

from itertools import combinations

ans = 0
for x1, x2 in combinations(D, 2):
    ans += x1*x2

print(ans)

Submission status: Accepted

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

total = 0

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

value = 0
for i in range(n):
  d1 = d[i]
  for j in d[i+1:]:
    d2 = j
    value += d1 * d2
    
print(value)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

def main():
    _ = input()
    d = [int(x) for x in input().split()]
    ans = 0
    for a, b in itertools.combinations(d, 2):
        ans += a * b
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    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
            else:
                ans += d[i] * d[j]
    print(ans // 2)
resolve()

Submission status: Accepted

Solution code:
if __name__ == "__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//2)

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())

d=np.array(input().split(),dtype=np.int32)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

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:
# Atcoder 2019/10/19
"""
# A
A, B = map(int, input().split())

ans = A - 2 * B

if ans >= 0:
    print(ans)
else:
    print(0)
"""

# B
import sys
n = int(input())
d = list(map(int, 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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[]
b=int(input())
for x in input().split(" "):
    a.append(int(x))

i=0
j=1
t=0

while i<b:
    while j<b:
        t+=a[i]*a[j]
        j+=1
    i+=1
    j=i+1
print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ds = list(map(int, input().split()))
# index: 0,...,N-1

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import itertools
import sys

input = sys.stdin.readline


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

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

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

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

X = 0

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

print(X)

Submission status: Accepted

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

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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

sum = 0
for i in range(N):
    sum += dList[i] * (dsum-dList[i])

sum /= 2
print(int(sum))

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n = int(input())
d = list(int(i) for i in input().split())

ans = 0
for l in range(n):
  for r in range(l + 1, n):
    if l == r:
      continue
    else:
      ans += (d[l] * d[r])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
import itertools
for com in itertools.combinations(range(n), r=2):
  x = d[com[0]]
  y = d[com[1]]
  sum += x * y

print(sum)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
dd=map(int,input().split())
from itertools import combinations
print(sum(a*b for a,b in combinations(dd,2)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
N = int(input())
Ds = list(map(int, input().split()))
if em: sys.stdin = open('/dev/tty')
sum = 0
for i in range(len(Ds)):
  for j in range(i + 1, len(Ds)):
    sum += Ds[i] * Ds[j]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

out = 0
for i in range(n-1):
    x = xs[i]
    nokori = sum(xs[i+1:])
    out += (x * nokori)
print(out)

Submission status: Accepted

Solution code:
n=int(input())
D=list(map(int,input().split()))
a=0
for i,d in enumerate(D):
  for j,e in enumerate(D):
    if i!=j:
    	a+=d*e
print(a//2)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
sum_d = sum(d)
rest = sum_d
res = 0
for i in range(len(d)):
  rest -= d[i]
  res += d[i] * rest
print(res)

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=sum(A)
count=0
for i in range(N):
    count+=A[i]**2
print((B**2-count)//2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n = int(input())
d = input()
d_list = d.split(" ")
d_int_list = []

for item in d_list:
    d_int_list.append(int(item))

ret = 0
for i in range(len(d_int_list)):
    for j in range(i+1, len(d_int_list)):
        ret += d_int_list[i] * d_int_list[j]

print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [int(e) for e in input().split()]

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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(i) for i in input().split()]

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


print(sum_d)

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

Solution code:
N = int(input())

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

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:
def f(D):
    n = len(D)
    sum_ = 0
    for first in range(n):
        for second in range(first + 1, n):
            deliciousness = D[first] * D[second]
            sum_ += deliciousness
    return sum_

assert f([3, 1, 2]) == 11
assert f([5, 0, 7, 8, 3, 3, 2]) == 312

N = int(input())
D = list(map(int, input().split()))
ans = f(D)
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:
import itertools
n = int(input())
D = [int(i) for i in input().split()]

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

Submission status: Accepted

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

sum = 0
for i in range(len(d_list)):
    for j in range(len(d_list)):
        if i == j:
            continue
        elif i > j:
            continue
        else:
            sum += d_list[i] * d_list[j]
            
print(sum)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
#-------------------------------------

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(x) for x in input().split()]

ans = []
for idx1 in range(n):
    for idx2 in range(n):
        if idx1 < idx2:
            ans.append(d[idx1]*d[idx2])
print(sum(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
d = [int(x) for x in 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 = input()
l = map(int, raw_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:
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())
takos = list(map(int, input().split()))

sum_delicious = 0

for i in range(N):
	x = takos[i]
	for j in range(i + 1, N):
		y = takos[j]
		sum_delicious += x * y

print(sum_delicious)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
D = [int(_) for _ in input().split()]
ans = 0
for a,b in combinations(D,2):
    ans +=a*b
print(ans)

Submission status: Accepted

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

print(total)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    


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

    
def main(): 
    res = 0
    for n in range(N-1):
        for m in range(n+1, N):
            res += D[n]*D[m]
    return print(res)
                
                
            
            
                

    
if __name__ == '__main__':
    main()



"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())


all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
# itemgetterには何番目の配列をキーにしたいか渡します
A, B, totAB = zip(*ABT)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
takoyaki = map(int, input().split(" "))

score = 0
for x, y in combinations(takoyaki, 2):
    score += x * y
print(score)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
dd = [x * y for x in d for y in d]
xx = [x * x for x in d]
print((sum(dd) - sum(xx)) // 2)

Submission status: Accepted

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

for i in range(n):
    a=a+d[i]

for i in range(n):
    b= b+d[i]*(a-d[i])

print(b//2)

Submission status: Accepted

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

Submission status: Accepted

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


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

print(score)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

from itertools import combinations
li2 = list(combinations(li,2))

point = 0
for i in range(len(li2)):
    point += (li2[i][0] * li2[i][1])

print(point)

Submission status: Accepted

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

Submission status: Accepted

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

def solve(N: int, d: "List[int]"):
    dd = list(itertools.combinations(d,2)) 
    answer = 0
    for ddd in dd:
        answer += ddd[0]*ddd[1]
    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
'''
import sys
input=sys.stdin.readline
n,m,c = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
from math import ceil
from collections import defaultdict ,Counter
'''
n = int(input())
a = list(map(int,input().split()))
su=0
for i in range(n):
    for j in range(i+1,n):
        su+=a[i]*a[j]
print(su)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
d = [int(i) for i in 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())
a=list(map(int,input().split()))

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

Submission status: Accepted

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

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

ans = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    d = [int(i) for i in input().split()]

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

    print(s)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(N - 1):
    d_i = int(D[i])
    for j in range(i + 1, N):
        d_j = int(D[j])
        ans += d_i * d_j

print(ans)

Submission status: Accepted

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

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:
input()
seq = [int(x) for x in input().split()]

ans = sum((x*y for i, x in enumerate(seq) for y in seq[i+1:]))
print(ans)

Submission status: Accepted

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

import itertools

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

res = 0
for x, y in c:
    res += x * y
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    d = list(map(int,input().split()))

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

    print(answer//2)

Submission status: Accepted

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

li = combinations(d,2)
ans = 0
for i, j in li:
  ans += i * j
print(ans)