Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N=int(input())
 
 
a = list(map(int, input().split()))
 
sum=a[0]
 
for i in range(1,N):
    sum = sum*a[i]
 
if sum<=1000000000000000000:
    print(sum)
else:
    print('-1')

### FIXED CODE ###

import numpy as np

N = int(input())

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

sum = a[0]


if 0 in a:
    print('0')
    exit()

for i in range(1, N):
    sum = sum * a[i]
    if sum > 10**18:
        print('-1')
        exit()

print(sum)
### BUGGY CODE ###

from collections import deque

N, P = map(int, input().split())

q = deque()

i = 2
c=0
ans=1
while(True):
    if(P%i==0):
        q.append(i)
        P=P//i
        c+=1
        if(c%N==0):
            ans*=i
    else:
        i+=1
        c=0
    

    if(P<i):
        break
print(ans)
    

### FIXED CODE ###

import collections

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

a=[]
while p % 2 == 0:
  p //= 2
  a.append(2)
f = 3
while f * f <= p:
  if p % f == 0:
    a.append(f)
    p //= f
  else:
    f += 2
if p != 1:
  a.append(p)

dct=collections.Counter(a)

ans=1

li=dct.items()

for tt in li:
  if tt[1]//n>=1:
    ans*=tt[0]**(tt[1]//n)
print(ans)
### BUGGY CODE ###

k,s = map(int, input().split())
count = 0
for h in range(0,k+1):
    for i in range(0,k+1):
        for j in range(0,k+1):
            if h + i +  j == s:
                count += 1
print(count)

### FIXED CODE ###

k,s = map(int, input().split())
count = 0
for h in range(0,k+1):
    for i in range(0,k+1):
        if 0 <= s - h - i <= k:
                count += 1
print(count)
### BUGGY CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    L = 100000

    N = NI()

    s = 1 if N > 0 else -1
    n = abs(N)

    bit = [0] * L

    i = 0
    while n > 0:
        if n % 2:
            bit[i] += 1
            if s > 0 and i % 2 == 1 or s < 0 and i % 2 == 0:
                bit[i+1] += 1
        n //= 2
        i += 1

    for i in range(L-2):
        if bit[i] > 1:
            bit[i+2] += bit[i] // 2
            bit[i+1] += bit[i] // 2
            bit[i] = bit[i] % 2

    f = False
    ans = ''
    for i in range(L-1,-1,-1):
        if bit[i] == 1:
            ans = ''.join((ans,'1'))
            f = True
        elif f:
            ans = ''.join((ans,'0'))
    if ans == '': ans = '0'

    print(ans)





if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    L = 1000

    N = NI()
    if N == 0:
        print(0)
        exit(0)

    s = 1 if N > 0 else -1
    n = abs(N)

    bit = [0] * L

    i = 0
    while n > 0:
        if n % 2:
            bit[i] += 1
            if s > 0 and i % 2 == 1 or s < 0 and i % 2 == 0:
                bit[i+1] += 1
        n //= 2
        i += 1

    for i in range(L-2):
        b = bit[i]
        if b > 1:
            b1 = bit[i+1]
            if b1 > 0:
                if b1 >= b//2:
                    bit[i+1] -= b//2
                    bit[i] = b % 2
                else:
                    bit[i+1] = 0
                    bit[i] -= b1 * 2
            if bit[i] > 1:
                bit[i+2] += bit[i] // 2
                bit[i+1] += bit[i] // 2
                bit[i] = bit[i] % 2

    bit.reverse()
    i = bit.index(1)
    print(*bit[i:],sep='')

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]

mmm=10**9+7
 

for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
result=0
for item in a:
  temp=ans//item
  result=(result+temp)%mmm
 
print(result)

### FIXED CODE ###

def main():
    from fractions import gcd
    import sys
    n=int(input())
    a = tuple(map(int, input().split()))
    ans = 1

    mmm=10**9+7
    for i in a:
        ans = ans *i // gcd(ans, i)

    result=0
    for item in a:
      result+=ans//item

    print(result%mmm)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, q = map(int, input().split())
s = list(input())
quiz = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    cnt = 0
    cnt_ac = 0
    for j in range(quiz[i][0] - 1, quiz[i][1]):
        if s[j] == "A":
            cnt += 1
        elif s[j] == "C" and cnt == 1:
            cnt_ac += 1
            cnt = 0
    print(cnt_ac)

### FIXED CODE ###

n, q = map(int, input().split())
s = list(input())
quiz = [list(map(int, input().split())) for _ in range(q)]

cnt_list = [0]*n
judge = 0

for i in range(n):
    if s[i] == "A":
        judge = 1
        cnt_list[i] = cnt_list[i-1]
    elif judge == 1 and s[i] == "C":
        judge = 0
        cnt_list[i] = cnt_list[i-1] + 1
    else:
        judge = 0
        cnt_list[i] = cnt_list[i-1]

for i in range(q):
    print(cnt_list[quiz[i][1] - 1] - cnt_list[quiz[i][0]-1])
### BUGGY CODE ###

def solve(n):
    global N, K
    dp = [[0] * (K + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(N):
        a = 0 if i == n else A[i]
        for j in range(max(0, K - a + 1)):
            here = dp[i][j]
            dp[i + 1][j + a] |= here
            dp[i + 1][j] |= here
    rst = any(dp[N][k] for k in range(max(0, K - A[n]), K))
    return rst


N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()


# [ok, ng) - Maximum
# (ng, ok] - Minimum
# ok が 最終的な答え
ok = N
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    n = mid
    dp = [[0] * (K + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(N):
        a = 0 if i == n else A[i]
        for j in range(K + 1):
            here = dp[i][j]
            dp[i + 1][min(K, j + a)] |= here
            dp[i + 1][j] |= here
    rst = any(dp[N][k] for k in range(max(0, K - A[n]), K))
    if rst:
        ok = mid
    else:
        ng = mid
print(ok)


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()


    # [ok, ng) - Maximum
    # (ng, ok] - Minimum
    # ok が 最終的な答え
    ok = N
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        n = mid
        dp = [0] * (K + 1)
        dp[0] = 1
        for i in range(N):
            a = A[i]
            if i == n or a >= K:
                continue
            for j in range(K, -1, -1):
                dp[min(K, j + a)] |= dp[j]
        rst = any(dp[k] for k in range(max(0, K - A[n]), K))
        if rst:
            ok = mid
        else:
            ng = mid
    print(ok)


main()
### BUGGY CODE ###

s = input()
k = int(input())

a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97+26
for m in b:
    a1 = [i for i in range(len(s)) if a[i] == m]

    for i in a1:
        j = 0
        while i+j < len(s) or j < k:
            if s[i:i+j+1] not in c:
                c.append(s[i:i+j+1])
                c.sort()
            if len(c) > 5:
                del c[-1]
            j += 1
    if len(c) >= k:
        break

print(c[k-1])


### FIXED CODE ###

s = input()
k = int(input())

a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97+26
for m in b:
    a1 = [i for i in range(len(s)) if a[i] == m]

    for i in a1:
        j = 0
        for j in range(k):
            if s[i:i+j+1] not in c:
                c.append(s[i:i+j+1])
                c.sort()
            if len(c) > 5:
                del c[-1]
            j += 1
            if i + j >= len(s):
                break
    if len(c) >= k:
        break

print(c[k-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

# ダムmin_indから決めていく
rain = [0 for i in range(N)]
start = 0
end = (start+N-1)%N
lim = min(A[end], A[start]) * 2
for r in range(lim, -1, -2):
    rain[start] = r
    now = (start+1)%N
    pre = start
    ok = False
    while now != start:
        rain[now] = (A[pre] - rain[pre] // 2) * 2
        if A[now] < rain[now]//2:
            break
        now = (now+1)%N
        pre = (pre+1)%N
    if now == start:
        if rain[now] == (A[pre] - rain[pre]//2) * 2:
            ok = True
    if ok:
        for i in range(N):
            print(rain[i], end="")
            if i != N-1:
                print(" ",end="")
            else:
                print()
        break


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

x = [0] * N
S = sum(A)
x[0] = S - 2 * (sum(A[1:N:2]))
for i in range(1, N):
    x[i] = 2 * A[i-1] - x[i-1]

for i in range(N-1):
    print(x[i], end=" ")
print(x[N-1])
### BUGGY CODE ###

s = input()
l = len(s)
k = int(input())


def compare(a, b):
    ll = [a, b]
    ll = sorted(ll)
    return ll[0] == a


db = []
for length in range(1, l + 1):
    for start in range(l + 1 - length):
        candidate = s[start:start+length]
        if len(db) >= 5:
            if compare(candidate, db[-1]):
                if candidate not in db:
                    db.append(candidate)
                    db = sorted(db)
                    db = db[:5]
        else:
            if candidate not in db:
                db.append(candidate)
                db = sorted(db)

print(sorted(db)[k-1])


### FIXED CODE ###

s = input()
l = len(s)
k = int(input())


def compare(a, b):
    ll = [a, b]
    ll = sorted(ll)
    return ll[0] == a


db = []
for length in range(1, k + 1):
    for start in range(l + 1 - length):
        candidate = s[start:start+length]
        if len(db) >= 5:
            if compare(candidate, db[-1]):
                if candidate not in db:
                    db.append(candidate)
                    db = sorted(db)
                    db = db[:5]
        else:
            if candidate not in db:
                db.append(candidate)
                db = sorted(db)

print(sorted(db)[k-1])
### BUGGY CODE ###

S=raw_input()
L=len(S)

M=10**9+7

dp=[ [ 0 for i in range(4) ] for k in range(L+1)]
all=1

for i in range(L):
	if S[i]=="A":
		dp[i+1][1]=( dp[i][1]+all ) %M
		dp[i+1][2]=dp[i][2]
		dp[i+1][3]=dp[i][3]
	if S[i]=="B":
		dp[i+1][2]=( dp[i][2]+dp[i][1] )%M
		dp[i+1][3]=dp[i][3]
		dp[i+1][1]=dp[i][1]
	if S[i]=="C":
		dp[i+1][3]=( dp[i][3]+dp[i][2] )%M
		dp[i+1][2]=dp[i][2]
		dp[i+1][1]=dp[i][1]

	if S[i]=="?":
		dp[i+1][1]=( dp[i][1]*3+all )%M
		dp[i+1][2]=( dp[i][2]*3+dp[i][1] )%M
		dp[i+1][3]=( dp[i][3]*3+dp[i][2] )%M
		all*=3	

print ( dp[-1][3] ) %M


### FIXED CODE ###

S=raw_input()

M=10**9+7

all=1
abc=0
ab=0
a=0

for x in S:
	if x=="A":
		a+=all
	if x=="B":
		ab+=a
	if x=="C":
		abc+=ab

	if x=="?":
		abc=abc*3+ab
		ab=ab*3+a
		a= a*3+all
		all*=3

	abc%=M
	ab%=M
	a%=M
	all%=M


print abc%M
### BUGGY CODE ###

N, M = map(int, input().split())

A = list(map(int, input().split()))
A.sort(reverse=True)

for i in range(M):
    A[0] //= 2
    j = 0
    if len(A) > 1:
        while A[j] < A[j+1] and j < len(A):
            A[j] , A[j+1] = A[j+1], A[j]
            j += 1
            if j >= len(A)-1:
                break

print(sum(A))

### FIXED CODE ###

import heapq
import math

N, M = map(int, input().split())

A = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(A)

for i in range(M):
    tmp = heapq.heappop(A)
    tmp = math.ceil(tmp / 2)
    heapq.heappush(A, tmp)

print(-sum(A))
### BUGGY CODE ###

N=int(input())
H=[int(s) for s in input().split()]

count_max=0
for j in range(N):
    count=0
    for i in range(j,N-1):
        if H[i]-H[i+1] >= 0:
            count+=1
        else:
            break
    if count > count_max:
        count_max=count
        X=j

print(count_max)

### FIXED CODE ###

N=int(input())
H=[int(s) for s in input().split()]

count_max=0
count=0
for i in range(N-1):
    if H[i]-H[i+1] >= 0:
        count+=1
        if count > count_max:
            count_max=count
    else:
        count=0

print(count_max)
### BUGGY CODE ###

import sys
s=input()
t=input()

def c(a,b,s,t):
    li=""
    j=0
    for i in s:
        if i==a:
            li+=b
            if t[j]!=b:
                print("No")
                sys.exit()
        elif i==b:
            li+=a
        else:
            li+=i
        j+=1
    return li
    
l=[]

for i in range(len(t)):
    if s[i]!=t[i]:
        for j in l:
            if s[i]==j:
                print("No")
                sys.exit()
        l.append(t[i])
        s=c(s[i],t[i],s,t)
    
        

if s==t:
    print("Yes")
else:
    print("No")
        
    

### FIXED CODE ###

s=input()
t=input()


def f(s):
    l=[]
    a="abcdefghijklmnopqrstuvwxyz"
    r=""
    for i in range(len(s)):
        if s[i] in l:
            for j in range(len(l)):
                if s[i]==l[j]:
                    r+=a[j]
        else:
            r+=a[len(l)]
            l.append(s[i])
    return r

if f(s)==f(t):
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

N, W = map(int, input().split())
knap = []
s_val = 0
for i in range(N):
    knap.append(tuple(map(int, input().split())))
    s_val += knap[i][1]
    
INF = 10**15
dp = [[INF for _ in range(s_val+1)] for _ in range(N+1)]  
dp[0][0] = 0

for i, (w, v) in enumerate(knap):
    for j in range(s_val+1):
        if(j >= v):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-v]+w)
        
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])

ans = 0
for i in range(s_val+1):
    if(dp[N][i] <= W):
        ans = i
print(ans)

### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
knap = []
for i in range(N):
    knap.append(tuple(map(int, input().split())))

s_val = sum([v for w, v in knap])
    
INF = float("inf")
dp = np.full(s_val+1, INF)
dp[0] = 0

for i, (w, v) in enumerate(knap):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
    
print(max([i for i in range(s_val+1) if dp[i] <= W]))
### BUGGY CODE ###

n,h=map(int,input().split())
a_l=[]
b_l=[]
c=0
for i in range(n):
  a,b=map(int,input().split())
  a_l.append(a)
  b_l.append(b)
a_l.sort()
b_l.sort()
for i in range(1,n+1):
  if a_l[-1]<=b_l[(-1)*i]:
    h-=b_l[(-1)*i]
    c+=1
    if h<=0:
      break
  else:
    break
while h>0:
  h-=a_l[-1]
  c+=1
print(c)

### FIXED CODE ###

import math
n,h=map(int,input().split())
a_l=[]
b_l=[]
c=0
for i in range(n):
  a,b=map(int,input().split())
  a_l.append(a)
  b_l.append(b)
a_l.sort()
b_l.sort()
for i in range(1,n+1):
  if a_l[-1]<=b_l[(-1)*i]:
    h-=b_l[(-1)*i]
    c+=1
    if h<=0:
      break
  else:
    break
if h>0:
  c+=math.ceil(h/a_l[-1])
print(c)
### BUGGY CODE ###

def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	maxNum = max(A)
	maxIndex = [i for i, x in enumerate(A) if x == max(A)]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(max(A[:maxIndex[0]]), max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
import fractions 
from functools import reduce
arr = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcma(numbers):
    return reduce(lcm_base, numbers, 1)
 
a = lcma(arr)

ans = [(a//i)%1000000007 for i in arr]
cnt=0
for i in ans:
    cnt += i %1000000007

print(cnt%1000000007)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
 
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a = 1
for i in range(N):
    a = lcm(a, A[i])
 
ans = 0
for i in range(N):
    ans += a * pow(A[i], mod-2, mod)
 
print(ans % mod)
### BUGGY CODE ###

# https://atcoder.jp/contests/apc001/tasks/apc001_c
# oは空席,mは男,fは女
# 奇数ならば必ずoは一つなければおかしい
# N=7のとき→mfmfomf oが奇数個だとoの両隣は必ず違う性別になる
# mfofmof
# mfomfof
# mfoofmf

# どの空席を見つけるか？奇数個のある方の空席を見つける
# mfm f omf だったら真ん中がfだったら右側にある
# mof m fmf だったら真ん中がmだったら左側にある
# mom f omo もできるからだめだ...

# 少なくとも1つは空席がある区間を二分探索する
# mfm f mof のように真ん中がfのとき左側はoが無いor 複数ある →右側には必ず一つ以上ある
# mfo m fof

# 二分探索したときに真ん中がfだと右側にoがある十分条件、 mだと左側にoがある十分条件
# ↑mから始まる場合。fから始まる場合は逆

N = int(input())

V = 'Vacant'
F = 'Female'
M = 'Male'
print(0, flush=True)
first = input()
if first == V:
    exit()
# print(N - 1, flush=True)
# right = input()
# if right == input():
#     exit()
left = 0
right = N - 1

# 二分探索
while True:
    mid = (left + right) // 2
    print(mid, flush=True)
    com = input()
    if com == V:
        exit()
    if com == first:
        # 左側を探索する十分条件
        right = mid - 1
    else:
        # 右側
        left = mid + 1


### FIXED CODE ###

# https://atcoder.jp/contests/apc001/tasks/apc001_c
# oは空席,mは男,fは女
# 奇数ならば必ずoは一つなければおかしい
# N=7のとき→mfmfomf oが奇数個だとoの両隣は必ず違う性別になる

# どの空席を見つけるか？奇数個のある方の空席を見つける
# mfm f omf だったら真ん中がfだったら右側にある
# mof m fmf だったら真ん中がmだったら左側にある
# mom f omo もできるからだめだ...

# 少なくとも1つは空席がある区間を二分探索する
# mfm f mof のように真ん中がfのとき左側はoが無いor 複数ある →右側には必ず一つ以上ある
# mfo m fof

# 二分探索したときに真ん中がfだと右側にoがある十分条件、 mだと左側にoがある十分条件
# ↑mから始まる場合。fから始まる場合は逆

N = int(input())

V = 'Vacant'
F = 'Female'
M = 'Male'
print(0, flush=True)
first = input()
if first == V:
    exit()
# print(N - 1, flush=True)
# right = input()
# if right == input():
#     exit()
left = 0
right = N - 1

# 二分探索
while True:
    mid = (left + right) // 2
    print(mid, flush=True)
    com = input()
    should_same = (mid - left) % 2 == 0  # oがなかったときにfirstと同じであるべきか？
    if should_same:
        cond = first == com
    else:
        cond = first != com

    if com == V:
        exit()
    if not cond:  # cond==Trueは左側は整っている
        # 左側を探索する十分条件
        right = mid - 1
    else:
        # 右側
        first = F if com != F else M
        left = mid + 1
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (N+1)
for i, a in enumerate(A):
    B[i+1] = B[i] + a%K
for i in range(N+1):
    B[i] -= i
    B[i] %= K
ans = 0
tbl = dict()
for i in range(min(K,N+1)):
    if B[i] not in tbl.keys():
        tbl[B[i]] = 1
    else:
        tbl[B[i]] += 1
        ans += tbl[B[i]] - 1
for i in range(K, N+1):
    tbl[B[i-K]] -= 1
    if B[i] not in tbl.keys():
        tbl[B[i]] = 1
    else:
        tbl[B[i]] += 1
        ans += tbl[B[i]] - 1
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (N+1)
for i, a in enumerate(A):
    B[i+1] = B[i] + a%K
for i in range(N+1):
    B[i] -= i
    B[i] %= K
ans = 0
# compress
C = B[::]
C.sort()
I = dict()
itmp = 0
I[C[0]] = 0
for i in range(1, N+1):
    if C[i] != C[i-1]:
        itmp += 1
        I[C[i]] = itmp

tbl = [0] * (N+1)
for i in range(min(K,N+1)):
    tbl[I[B[i]]] += 1
    ans += tbl[I[B[i]]] - 1
for i in range(K, N+1):
    tbl[I[B[i-K]]] -= 1
    tbl[I[B[i]]] += 1
    ans += tbl[I[B[i]]] - 1
print(ans)
### BUGGY CODE ###

import collections
n = int(input())
a = list(map(str,input().split()))

c = collections.Counter(a)

comon = c.most_common()
ans = 0

for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
    for j in comon:
      if i == j[0]:
        co = j[1]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

### FIXED CODE ###

import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))
### BUGGY CODE ###

from itertools import combinations
N = int(input())
A = list(map(int, input().split()))
m = 1000000007
b = [(c[0]^c[1])%m for c in combinations(A,2)]
print(sum(b)%m)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
count = [0] * 60
m = 1000000007
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K * x) % 1000000007
        x = (x * x) % 1000000007
        n //= 2
    return (K * x) % 1000000007
mul = [pow_k(2,59-i) for i in range(60)]
for a in A:
    b = bin(a)
    for i in range(1,len(b)-1):
        if b[-i] == '1':
            count[-i] += 1
print(sum([count[i]*(N-count[i])*mul[i]%m for i in range(60)])%m)
### BUGGY CODE ###


n, m = map(int, input().split())
sumans = 0
ans = 0

list = [[0 for i in range(2)] for j in range(n)]
#print(list)

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

#print(sorted(list))
	
list = sorted(list)

for i in range(n):
	for j in range(int(list[i][1])):
		sumans += list[i][0]
		ans += 1
		if ans == m:
			print(sumans)

### FIXED CODE ###

import sys
n, m = map(int, input().split())
sumans = 0
ans = 0

list = [[0 for i in range(2)] for j in range(n)]

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

for i in range(n):
	for j in range(int(list[i][1])):
		sumans += list[i][0]
		ans += 1
		if ans == m:
			print(sumans)
			sys.exit()
### BUGGY CODE ###

import itertools 

line1 = input().split()
rei =input().split()
den =input().split()
cupon =[list(map(int,input().split())) for i in range(int(line1[2]))]
rei_den =list(itertools.product(rei , den))
sum_rei_den =[0]*len(rei_den)

for i in range(len(rei_den)):
  sum_rei_den[i] = int(rei_den[i][0])+ int(rei_den[i][1])

mi = min(sum_rei_den)

for s in range(int(line1[2])):
  total =int(rei[cupon[s][0]-1]) +int(den[cupon[s][1]-1]) - cupon[s][2]
  if mi > total:
    mi =total
print(mi)

### FIXED CODE ###

import itertools 

line1 = input().split()
rei = input().split()
rei =list(map(int,rei))
den =input().split()
den =list(map(int,den))
cupon =[list(map(int,input().split())) for i in range(int(line1[2]))]

rei_mi = min(rei)
den_mi =min(den)

no_total =rei_mi +den_mi

for s in range(int(line1[2])):
  yes_total =int(rei[cupon[s][0]-1]) +int(den[cupon[s][1]-1]) - cupon[s][2]
  if no_total > yes_total:
    no_total =yes_total
print(no_total)
### BUGGY CODE ###

#ABC162c
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
abc = 0
for i in range(k):
    for i2 in range(k):
        for i3 in range(k):
            abc += gcd(i+1, i2+1, i3+1)
print(abc)


### FIXED CODE ###

#ABC162c
from math import gcd
K = int(input())+1
Sum = 0
for i in range(1,K):
    for j in range(1,K):
        d = gcd(i,j)
        for k in range(1,K):
            Sum+=gcd(d,k)

print(Sum)
### BUGGY CODE ###

n = int(input())
board = [1] * (n+1)

def divisor_num(n, board):
    for i in range(2, n+1):
        j = 1
        while i*j <= n:
            board[i*j] += 1
            j += 1

divisor_num(n, board)
res = sum([i * board[i] for i in range(1, n+1)])
print(res)


### FIXED CODE ###

n = int(input())
board = [1] * (n+1)

def divisor_num(n, board):
    for i in range(2, n+1):
        j = 1
        while i*j <= n:
            board[i*j] += 1
            j += 1

divisor_num(n, board)
res = sum([i * board[i] for i in range(1, n+1)])
print(res)