Harryxun/stf_run huggingface dataset:
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b.sort(reverse = True)
b_k = b[2k]
a_new = [a[i] for i in range(len(a)) if np.abs(a)[i] > b_k]

comb = itertools.combinations(a_new,k)  
l = [list(_) for _ in comb]  
A = (functools.reduce(operator.mul,l[_]) for _ in range(len(l)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
import numpy as np
hp, n = map(int,input().split())

list = np.zeros((n,2))
for i in range(n):
    list[i][0], list[i][1] = map(int,input().split())

dp = np.full((n+1, hp+1), 100000000000000000)

dp[0][0] = 0
for i, lista in enumerate(dp):
    dp[i][0] = 0
    for j, value in enumerate(lista):
        if i == 0:
            continue
        if j < list[i-1][0]:
            dp[i][j] = min(list[i-1][1], dp[i-1][j])
        else:
            target = int(j - list[i-1][0])
            dp[i][j] = min((dp[i][target] + list[i-1][1]), dp[i-1][j])

print(dp[n][hp])




### FIXED CODE ###


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

list = [[0] * 2 for i in range(n)]
for i in range(n):
    list[i][0], list[i][1] = map(int,input().split())

dp = [[10000000000] * (hp+1) for i in range(n+1)]

dp[0][0] = 0
for i, lista in enumerate(dp):
    dp[i][0] = 0
    for j, value in enumerate(lista):
        if i == 0:
            continue
        if j < list[i-1][0]:
            dp[i][j] = min(list[i-1][1], dp[i-1][j])
        else:
            target = j - list[i-1][0]
            dp[i][j] = min((dp[i][target] + list[i-1][1]), dp[i-1][j])

print(int(dp[n][hp]))
Tmp = []
Tmp = input().rstrip().split(',')

Ans = []

nA = int(Tmp[0])
Ans.append(nA)

nB = int(Tmp[1])
Ans.append(nB)
  
nC = int(Tmp[2])
Ans.append(nC)

Ans.sort(reverse='True')

nAns = Ans[0]*10+Ans[1]+Ans[2]
print(nAns)



### FIXED CODE ###

Tmp = []
Tmp = input().rstrip().split(' ')
 
Ans = []
 
nA = int(Tmp[0])
Ans.append(nA)
 
nB = int(Tmp[1])
Ans.append(nB)
  
nC = int(Tmp[2])
Ans.append(nC)
 
Ans.sort(reverse=True)
 
nAns = Ans[0]*10+Ans[1]+Ans[2]
print(nAns)
n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]
h.sort()
print(min(h[k + ki - 1] - h[ki] for ki in range(k)))

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]
h.sort()
print(min(h[k + ki - 1] - h[ki] for ki in range(n - k + 1)))
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
y = [x[i] - x[i - 1] for i in range(1, m)]
y.sort()
result = 0
for i in range(n - m):
  result += y[i]
print(result)


### FIXED CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
y = [x[i] - x[i - 1] for i in range(1, m)]
y.sort()
print(sum(y[:m-n]) if n < m else 0)
# -*- coding: utf-8 -*-
import sys

s = (input().split(' '))

n,m = [int(i) for i in s]

l_list = []
r_list = []

for i in range(m):
    s = (input().split(' '))
    l,r = [int(i) for i in s]
    l_list.append(l)
    r_list.append(r)

range = (max(l_list), min(r_list))

if range[0] > range[1]:
    print(0)
else:
    print(range[1] - range[0] + 1))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

s = (input().split(' '))

n,m = [int(i) for i in s]

l_list = []
r_list = []

for i in range(m):
    s = (input().split(' '))
    l,r = [int(i) for i in s]
    l_list.append(l)
    r_list.append(r)

range = (max(l_list), min(r_list))

if range[0] > range[1]:
    print(0)
else:
    print(range[1] - range[0] + 1)
import itertools
import heapq
n,k = map(int,input().split())
a = list(map(int,input().split()))
if n>=2k:
  a_plus = heapq.nlargest(k, a)
  a_minus = heapq.nsmallest(k, a)
  a_new = a_plus+a_minus
  comb = itertools.combinations(a_new,k)
else:
  comb = itertools.combinations(a,k)
 
l = []
for i in comb:
  l.append(list(i))
  
A = []
one = [1]*len(l)
for i in range(len(l)):
  for j in range(k):
    one[i]*=l[i][j]
    A.append(one[i])
    
l_max = max(one)
waru = 10**9 + 7
 
mod = l_max % waru
print(mod)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
import sys
a,b,c = map(int,input().split())
if a == b == c:
    print(-1)
    sys.eixt()
count = 0
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    x = (b+c)//2
    y = (a+c)//2
    z = (a+b)//2
    a,b,c = x,y,z
    count+=1
    #print(a,b,c)
print(count)

### FIXED CODE ###

import sys
a,b,c = map(int,input().split())
if a == b == c and a%2 == b%2 == c%2== 0:
    print(-1)
    sys.exit()
count = 0
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    x = (b+c)//2
    y = (a+c)//2
    z = (a+b)//2
    a,b,c = x,y,z
    count+=1
    #print(a,b,c)
print(count)
if a == b and a != c:
    print(c)
elif a != b and a == c:
    print(b)
else:
    print(a)

### FIXED CODE ###

a, b, c = map(int, input().split())

if a == b and a != c:
    print(c)
elif a != b and a == c:
    print(b)
else:
    print(a)
l = raw_input().split()
print l[0]*l[1]

### FIXED CODE ###

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

print(i[0]*i[1], i[0]*2+i[1]*2)
return (A-1)*(B-1);

### FIXED CODE ###

a=input().split();print((int(a[0])-1)*(int(a[1])-1));
t=input().split(" ")
X=int(t[0])
Y = int(t[1])
Z = int(t[2])
print((X-Z)//(Y+Z))

### FIXED CODE ###

t=input().split(" ")
X=(t[0])
Y =(t[1])
if X>Y:
    print(">")
if X<Y:
    print("<")
if X==Y:
    print("=")
while 1:
    n = int(input())
    if n == 0:
        break
    S = [input() for i in range(n)]

    dup = [0]*n
    for i in range(n):
        si = S[i]
        for j in range(i+1, n):
            sj = S[j]
            if si.find(sj)+1:
                dup[j] = 1
            if sj.find(si)+1:
                dup[i] = 1
    S = [S[i] for i in range(n) if not dup[i]]
    n -= sum(dup)

    P = [[0]*n for i in range(n)]
    D = [[0]*n for i in range(n)]
    for i in range(n):
        si = S[i]
        l = len(si)
        for j in range(n):
            sj = S[j]
            pos = l
            for k in range(l):
                if sj.startswith(si[k:]):
                    pos = k
                    break
            P[i][j] = len(sj) - (l - pos)
            D[i][j] = l - pos

    Q = [[] for i in range(300)]
    for i in range(n):
        Q[len(S[i])].append((1 << i, i, 0))
    ALL = 2**n-1
    up = sum(map(len, S))
    border = up
    memo = {(1 << i, i): len(S[i]) for i in range(n)}
    l = 0
    while l < border:
        for state, i, d in Q[l]:
            if memo[state, i] < l:
                continue
            for j in range(n):
                if (state >> j) & 1 < 1:
                    ncost = l + P[i][j]
                    nstate = state | (1 << j)
                    if (nstate, j) not in memo or ncost < memo[nstate, j]:
                        border = min(border, up - d - D[i][j])
                        if ncost <= border:
                            memo[nstate, j] = ncost
                            Q[ncost].append((nstate, j, d+D[i][j]))
        l += 1
    print(border)

### FIXED CODE ###

while 1:
    n = int(input())
    if n == 0:
        break
    S = [input() for i in range(n)]

    dup = [0]*n
    for i in range(n):
        si = S[i]
        for j in range(i+1, n):
            sj = S[j]
            if si.find(sj)+1:
                dup[j] = 1
            if sj.find(si)+1:
                dup[i] = 1
    S = [S[i] for i in range(n) if not dup[i]]
    n -= sum(dup)

    P = [[0]*n for i in range(n)]
    for i in range(n):
        si = S[i]
        l = len(si)
        for j in range(n):
            sj = S[j]
            pos = l
            for k in range(l):
                if sj.startswith(si[k:]):
                    pos = k
                    break
            P[i][j] = len(sj) - (l - pos)

    ALL = 2**n - 1
    up = 300
    memo = {(ALL, i): 0 for i in range(n)}
    def dfs(state, i):
        if (state, i) in memo:
            return memo[state, i]
        res = up
        for j in range(n):
            if (state >> j) & 1 < 1:
                res = min(res, dfs(state | (1 << j), j) + P[i][j])
        memo[state, i] = res
        return res
    print(min(dfs(1 << i, i) + len(S[i]) for i in range(n)))
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
for i in range(n):
    if d <= x:
        d += l[i]
    else:
        break
print(i)

### FIXED CODE ###

x, a = map(int, input().split())
if x < a :
    print(0)
else:
    print(10)
n = int(input())
k = int(input())
if k == 1:
  flag = True
  cnt = 0
  while flag:
    for i in range(101):
      for j in range(1,10):
        if j*(10**i) <= n:
          cnt += 1
        else:
          flag = False
          break
elif k == 2:
  flag = True
  cnt = 0
  while flag:
    for i in range(1,101):
      for j in range(1,10):
        for l in range(i):
          for m in range(1,10):
            if j*(10**i)+m*(10**l) <= n:
              cnt += 1
            else:
              flag = False
              break
else:
  print(0)
print(cnt)


### FIXED CODE ###

n = input()
k = int(input())
dp = [[[0,0,0,0],[0,0,0,0]] for i in range(len(n))] #dp[p][0][count]は、p桁目まではnより小さいことが確定している
#countは「0以外の桁」の登場回数、あくまで各桁に登場したt「以下」の数字かどうかを判定する。dp[p][1]は「〜と同じ」
dp[0][0][0] = 0
dp[0][0][1] = 1
dp[0][1][0] = 1
dp[0][1][1] = int(n[0])-1
for i in range(1,len(str(n))):
    if n[i] != '0':
        dp[i][0][0] = 0 #遷移前に同じで、遷移後に0でないものが0個かつ遷移前と同じ遷移はありえない
        dp[i][0][1] = dp[i-1][0][0] #ぴったりの数字(0でない)が入ればOK 下二つも同じ
        dp[i][0][2] = dp[i-1][0][1]
        dp[i][0][3] = dp[i-1][0][2]
        dp[i][1][0] = dp[i-1][1][0] #0を入れればOK
        dp[i][1][1] = dp[i-1][0][0]*(max(0,int(n[i])-1))+dp[i-1][0][1]+dp[i-1][1][1]+dp[i-1][1][0]*9
        dp[i][1][2] = dp[i-1][0][1]*(max(0,int(n[i])-1))+dp[i-1][0][2]+dp[i-1][1][2]+dp[i-1][1][1]*9
        dp[i][1][3] = dp[i-1][0][2]*(max(0,int(n[i])-1))+dp[i-1][0][3]+dp[i-1][1][3]+dp[i-1][1][2]*9
    else:
        dp[i][0][0] = dp[i-1][0][0]
        dp[i][0][1] = dp[i-1][0][1]
        dp[i][0][2] = dp[i-1][0][2]
        dp[i][0][3] = dp[i-1][0][3]
        dp[i][1][0] = dp[i-1][1][0] #0を入れればOK
        dp[i][1][1] = dp[i-1][1][0]*9+dp[i-1][1][1]
        dp[i][1][2] = dp[i-1][1][1]*9+dp[i-1][1][2]
        dp[i][1][3] = dp[i-1][1][2]*9+dp[i-1][1][3]
print(dp[len(n)-1][0][k]+dp[len(n)-1][1][k])
whlie True:
    a, b = row_input().strip().split(" ")
    print len(str(int(a) + int(b))))

### FIXED CODE ###

#condig: UTF-8
 
while True:
    try:
        n = map(int, raw_input().split())
        s = len(str(n[0] + n[1]))
        print s
    except Exception:
        break
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
k=[[int(i) for i in input().split()] for i in range(m)]
k=sorted(k,key=lambda x:-x[1])

now=0
flag=True
for x,y in k:
    if flag:
        for i in range(x):
            if flag:
                if y>a[i+now]:
                    a[i+now]=y
                else:
                    flag=False
    now+=x
print(sum(a))

### FIXED CODE ###

def main():
    import sys
    input=sys.stdin.readline
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    a=sorted(a)
    k=[[int(i) for i in input().split()] for i in range(m)]
    k=sorted(k,key=lambda x:-x[1])
    
    now=0
    flag=True
    for x,y in k:
        if flag:
            for i in range(x):
                if i+now>=n:
                    print(sum(a))
                    exit()
                if flag:
                    if y>a[i+now]:
                        a[i+now]=y
                    else:
                        flag=False
        now+=x
    print(sum(a))
if __name__=="__main__":
    main()
a = list(map(int,input().split()))
    print(max(a[2]-(a[0]-a[1]),0))


### FIXED CODE ###

a = list(map(int,input().split()))
if a[2]>(a[0]-a[1]):
    print(a[2]-(a[0]-a[1]))
else:print(0)
import sys
from io import StringIO
import unittest

class Okojo:
    def __init__(self, line):
        self.line = line
        self.l = []
        self.r = []
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.l.append(i)
            else:
                self.r.append(i)

    def get_next(self, state):
        nex = [0] * len(self.line)
        for i in range(len(self.l)):
            nex[self.l[i] - 1] += state[self.l[i]]
        for i in range(len(self.r)):
            nex[self.r[i] + 1] += state[self.r[i]]
        return nex


def resolve():
    input = sys.stdin.readline
    line = input()

    okojo = Okojo(line)

    now = [1] * len(line)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if before1 == now:
            break
        elif before2 == now:
            if i % 2 == 0:
                now = before1
            break

    print(*now)
    
resolve()

### FIXED CODE ###

def resolve():
    line = input()
    result = [0] * len(line)

    r_odd = 0
    r_even = 0
    for i in range(len(line)):
        if line[i] == 'L':
            if i % 2 == 0:
                result[i] += r_even
                result[i-1] += r_odd
            else:
                result[i] += r_odd
                result[i-1] += r_even
            r_odd = 0
            r_even = 0
        elif line[i] == 'R':
            if i % 2 == 0:
                r_even += 1
            else:
                r_odd += 1
    l_odd = 0
    l_even = 0
    for i in range(len(line)-1, -1, -1):
        if line[i] == 'R':
            if i % 2 == 0:
                result[i] += l_even
                result[i+1] += l_odd
            else:
                result[i] += l_odd
                result[i+1] += l_even
            l_odd = 0
            l_even = 0
        elif line[i] == 'L':
            if i % 2 == 0:
                l_even += 1
            else:
                l_odd += 1

    print(*result)
    
resolve()
a,b = list(map(int,input()))

print(0 if a%b==0 else 1)

### FIXED CODE ###

a,b = list(map(int,input().split()))

print(0 if a%b==0 else 1)
INF = 10 ** 20
 
N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(N+1)
dp[0] = 0

for i in range(coin,N+1):
    for coin in coin_list:
        dp[i] = min(dp[i], dp[i-coin]+1)
 
print(dp[N])

### FIXED CODE ###

INF = 10 ** 20

N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(N+1)
dp[0] = 0
 
for coin in coin_list:
    for i in range(coin,N+1):
        dp[i] = min(dp[i], dp[i-coin]+1)
 
print(dp[N])
import sys
S=input()
if len(S)>1:
    for i in range(n//2):
        s=S[2*i]
        if s=="L":
            print("No")
            sys.exit()
        s=S[2*i+1]
        if s=="R":
            print("No")
            sys.exit()
if len(S)%2==1:
    s=S[-1]
    if s=="L":
        print("No")
        sys.exit()
print("Yes")

### FIXED CODE ###

import sys
S=input()
n=len(S)
if n>1:
    for i in range(n//2):
        s=S[2*i]
        if s=="L":
            print("No")
            sys.exit()
        s=S[2*i+1]
        if s=="R":
            print("No")
            sys.exit()
if n%2==1:
    s=S[-1]
    if s=="L":
        print("No")
        sys.exit()
print("Yes")
s = input()
c = 0
for i in range(3):
  if a[i] == "○":
    c += 1
print(700 + 100*c)

### FIXED CODE ###

s = input()
c = 0
for i in range(3):
  if s[i] == "o":
    c += 1
print(700 + c*100)
from collections import defaultdict
from fractions import Fraction
import sys
input = sys.stdin.readline

mod = 1000000007
n = int(input())

a_per_b = defaultdict(int)
minus_b_per_a = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    x = Fraction(a, b)
    y = -Fraction(b, a)
    a_per_b[x] += 1
    minus_b_per_a[y] += 1


def inverse(f):
    return Fraction(f.denominator, f.numerator)


ans = 1
calculated = set()
for key, count in a_per_b.items():
    if key in calculated:
        continue

    if key in minus_b_per_a:
        bad_count = minus_b_per_a[key]
        ans *= pow(2, count+bad_count, mod) - (pow(2, count, mod) - 1) * (pow(2, bad_count, mod) - 1) % mod
        ans %= mod
        calculated.add(-inverse(key))
    else:
        ans *= pow(2, count, mod)
        ans %= mod

print(ans - 1)


### FIXED CODE ###

from collections import defaultdict
from math import gcd

mod = 10 ** 9 + 7
n = int(input())
fishes = defaultdict(int)
zero_zero = 0
zero = 0
inf = 0

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero_zero += 1

    elif a == 0:
        zero += 1

    elif b == 0:
        inf += 1

    else:
        div = gcd(a, b)
        a //= div
        b //= div
        if b < 0:
            a *= -1
            b *= -1
        key = (a, b)
        fishes[key] += 1


def get_bad_pair(fish):
    a, b = fish
    if a < 0:
        a *= -1
        b *= -1
    return (-b, a)


ans = 1
counted_key = set()
for fish_key, count in fishes.items():
    if fish_key in counted_key:
        continue

    bad_pair = get_bad_pair(fish_key)
    if bad_pair in fishes:
        pair_count = fishes[bad_pair]
        pattern = pow(2, count, mod) + pow(2, pair_count, mod) - 1
        counted_key.add(bad_pair)

    else:
        pattern = pow(2, count, mod)

    ans = ans * pattern % mod

ans *= pow(2, zero, mod) + pow(2, inf, mod) - 1
if zero_zero:
    ans += zero_zero

ans -= 1
print(ans % mod)
import math

S = int(input())

ans = [0, 0]
limit = 10 ** 9
seki = S + 10 ** 6
for i in range(1, 10**9):
    div = seki % j
    if div == 0:
        if j > limit or seki // j > limit:
            continue
        ans += [j, 1, 10 ** 9, seki // j]
        print(*ans)
        exit()


### FIXED CODE ###

import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)
n = int(input())
n2 = n/2
v = [int(i) for i in input().split()]
v1 = []
v2 = []
for i in range(n):
    if(i % 2 == 0):
        v1.append(v[i])
    else:
        v2.append(v[i])
count1 = [v1.count(v1[i]) for i in range(int(n2))]
count2 = [v2.count(v2[i]) for i in range(int(n2))]
if(v1[count1.index(max(count1))] == v2[count2.index(max(count2))]):
    max1 = max(count1)
    max2 = max(count2)
    count1 = list(set(count1))
    count1.remove(max(count1))
    count2 = list(set(count2))
    count2.remove(max(count2))
    if(max(count1) > max(count2)):
        print(n - max(count1) - max2)
    else:
        print(n - max(count2) - max1)
else:
    print(n - max1 - max2)


### FIXED CODE ###

from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1mc = v1.most_common()
v2mc = v2.most_common()
if(v1mc[0][0] == v2mc[0][0]):
    if(len(v1mc) == 1 and len(v2mc) == 1):
        print(int(n/2))
    elif(len(v1mc) == 1):
        print(n - (v1mc[0][1]+v2mc[1][1]))
    elif(len(v2mc) == 1):
        print(n - (v2mc[0][1]+v1mc[1][1]))
    else:
        print(n - max(v1mc[0][1]+v2mc[1][1], v2mc[0][1]+v1mc[1][1]))
else:
    print(n - (v1mc[0][1]+v2mc[0][1]))
N = int(input())
arr = list(map(int, input().split()))

ans = 0
for i in range(N):
    for i in range(i+1,N):
        ans += i*J

print(ans)

### FIXED 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)
import math
a,b,c,d=map(int,input().split())

e=int(c*d/math.gcd(c,d))
x1=(a-1)//c
x2=b//c
y1=(a-1)//d
y2=b//d
z1=(a-1)//e
z2=b//e


print(int(b-a+1-(x2-x1+y2-y1-(z2-z1))))     


### FIXED CODE ###

a,b,c,d=map(int,input().split())
import fractions


lcm=int(c*d/fractions.gcd(c,d))

cc=b//c-(a-1)//c
dd=b//d-(a-1)//d
cd=b//lcm-(a-1)//lcm

print((b-a+1)-(cc+dd-cd))
import os, sys, re, math

(N, K) = [int(n) for n in input().split()]

lk = math.log2(K - 1)

p = 0
for i in range(1, N + 1):
    if i >= K:
        p += 1.0
    else:
        p += (0.5 ** (int(lk - math.log2(i) + 1)))

print(p / N)


### FIXED CODE ###

import os, sys, re, math

(N, K) = [int(n) for n in input().split()]

if K == 1:
    print(1)
else:
    lk = math.log2(K - 1)
    p = 0
    for i in range(1, N + 1):
        if i >= K:
            p += 1.0
        else:
            p += (0.5 ** (int(lk - math.log2(i) + 1)))
    print(p / N)