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

import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        for j in range(root+1):
            if n % i == 0 and n != 0:
                cnt += 1
                n = n // i
            else:
                break
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()
    L = {}
    B = [0] * N
    primes_a = {}
    for a in A:
        prime_a = prime_fact(a)
        primes_a[a] = prime_a
        for p, n in prime_a.items():
            L.setdefault(p, 0)
            L[p] = max(L[p], n)
    for i, a in enumerate(A):
        b = 1
        for p, n in L.items():
            primes_a[a].setdefault(p, 0)
            b *= pow(p, (n - primes_a[a][p]), MOD)
        B[i] = b
    print(sum(B) % MOD)



if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        for j in range(root+1):
            if n % i == 0 and n != 0:
                cnt += 1
                n = n // i
            else:
                break
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()
    L = {}
    primes_a = {}
    for a in A:
        prime_a = prime_fact(a)
        primes_a[a] = prime_a
        for p, n in prime_a.items():
            L.setdefault(p, 0)
            L[p] = max(L[p], n)
    ans = 0
    l = 1
    for p, n in L.items():
        l = l * pow(p, n, MOD) % MOD

    for i, a in enumerate(A):
        ans += l * pow(a, MOD-2, MOD) % MOD
    print(ans % MOD)



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

x, y, z, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))[:k]

e = []

for va in a:
    for vb in b:
        e.append(va+vb)

e.sort(reverse=True)

e = e[:k]

d = []
for vc in c:
    for ve in e:
        d.append(vc+ve)

d.sort(reverse=True)
d = d[:k]

for vd in d:
    print(vd)

### FIXED CODE ###

import heapq

x, y, z, k = map(int, input().split())

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

e = []

for va in a:
    for vb in b:
        e.append(va+vb)

e.sort(reverse=True)
e = e[:k]

d = []
for ve in e:
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print(-heapq.heappop(d))
### BUGGY CODE ###

import itertools
N, K = map(int, input().split())

num_list = []
for n in range(0,N+1):
    num_list.append(n)

ans_list = []
for k in range(K,N+2):
    for i in itertools.permutations(num_list, k):
        if not (len(i),sum(i)) in ans_list:
            ans_list.append((len(i),sum(i)))
            
print(len(ans_list))

### FIXED CODE ###

N, K = map(int, input().split())
mod = 10**9+7
ans= 0
for k in range(K, N + 2):
    min_num = ((k-1) * k) / 2
    max_num = (N * (N+1)) / 2 - ((N-k) * (N-k+1)) / 2
    ans +=  max_num - min_num + 1
print(int(ans % mod))
### BUGGY CODE ###

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


def min_point(data):
    lgt = len(data)
    m=0
    ins=0
    for i in range(lgt):
        if i ==0:
            buf = min(data[i],data[lgt-1])
        else:
            buf = min(data[i],data[i-1])
        if buf > m:
            m=buf
            ins=i
    return [m,ins]

a.sort(reverse=True)
cnt=0
lst=[]
for i in range(n):
    if i == 0:
        lst.append(a[i])
    elif len(lst) == 1:
        cnt += lst[0]
        lst.append(a[i])
    else:
        mp = min_point(lst)
        cnt += mp[0]
        lst.insert(mp[1], a[i])

print(cnt)

### FIXED CODE ###

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


a.sort(reverse=True)
cnt=0
for i in range(1,n):
    if i==1:
        cnt+=a[0]
    else:
        j = (i // 2)
        cnt += a[j]
print(cnt)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    input_q = list(map(int, input().split()))
    B.append(input_q[0])
    C.append(input_q[1])

for i in range(Q):
    A = [C[i] if j == B[i] else j for j in A]
    print(sum(A))


### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    input_q = list(map(int, input().split()))
    B.append(input_q[0])
    C.append(input_q[1])
    
A_sum = sum(A)
CONST_MAX = 100001
count_list = [0] * CONST_MAX

c = collections.Counter(A)
for k, v in c.items():
    # print(k, v)
    count_list[k] = v


for i in range(Q):
    count_list[C[i]] += count_list[B[i]]
    A_sum += (C[i] - B[i]) * count_list[B[i]]
    count_list[B[i]] = 0
    # print(count_list)

    print(A_sum)
### BUGGY CODE ###

N=int(input())
n_list= list(map(int,input().split()))
if 0 in n_list :
  print('0')
else:  
  ans=1
  tho=10**18
  for i in range (N):
    ans*=n_list[i]
  if ans > tho :
    print('-1')
  else :
    print(ans)

### FIXED CODE ###

N = int(input())
n_list = list(map(int,input().split()))
if 0 in n_list :
  print('0')
else:  
  ans = 1
  tho = 10**18
  for i in range (N):
    ans *= n_list[i]
    if ans > tho :
      print('-1')
      break
  if ans <= tho :
    print(ans)
### BUGGY CODE ###

n = int(input())

train_list = []
for i in range(n-1):
    array = list(map(int,input().split()))
    train_list.append(array)

for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        if i == j:
            time += (train_list[i][0] + train_list[i][1])
        else:
            flag = False
            p = 0
            while flag is False:
                t = train_list[j][1] + train_list[j][2] * p
                if t // time >= 1:
                    flag = True
                    time = t
                    time += train_list[j][0]
                p += 1

    print(time)

print(0)


### FIXED CODE ###

import math
n = int(input())

train_list = []
for i in range(n-1):
    array = list(map(int,input().split()))
    train_list.append(array)


for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        if i == j:
            time += (train_list[i][0] + train_list[i][1])
        else:
            if train_list[j][1] // time >= 1:
                time = train_list[j][1]
                time += train_list[j][0]
            else:
                p = math.ceil((time - train_list[j][1])/train_list[j][2])
                time = train_list[j][1] + train_list[j][2] * p
                time += train_list[j][0]
    print(time)

print(0)
### BUGGY CODE ###

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

ans = 0
seat = [[min(i, j, n-i-1, n-j-1) for j in range(n)] for i in range(n)]
reserved = [[True for j in range(n)] for i in range(n)]

vec = [(-1, 0), (1, 0), (0, -1), (0, 1)]


def bfs(x, y):
    q = [(x, y)]
    while q:
        x, y = q.pop()
        for dx, dy in vec:
            x1 = x+dx
            y1 = y+dy
            if 0 <= x1 < n and 0 <= y1 < n and seat[x1][y1] > seat[x][y]:
                seat[x1][y1] = seat[x][y] + reserved[x][y]
                q.append((x1, y1))


for i in range(n**2):
    v = p[i]-1
    x, y = v//n, v % n
    reserved[x][y] = False
    ans += seat[x][y]
    bfs(x, y)

print(ans)


### FIXED CODE ###

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

ans = 0
seat = [[min(i, j, n-i-1, n-j-1) for j in range(n)] for i in range(n)]
reserved = [[True for j in range(n)] for i in range(n)]

vec = [(-1, 0), (1, 0), (0, -1), (0, 1)]

for i in range(n**2):
    v = p[i]-1
    x, y = v//n, v % n
    reserved[x][y] = False
    ans += seat[x][y]
    q = [(x, y)]
    while q:
        x, y = q.pop()
        if 0 <= x+1 < n and 0 <= y < n and seat[x+1][y] > seat[x][y] + reserved[x][y]:
            seat[x+1][y] = seat[x][y] + reserved[x][y]
            q.append((x+1, y))
        if 0 <= x-1 < n and 0 <= y < n and seat[x-1][y] > seat[x][y] + reserved[x][y]:
            seat[x-1][y] = seat[x][y] + reserved[x][y]
            q.append((x-1, y))
        if 0 <= x < n and 0 <= y+1 < n and seat[x][y+1] > seat[x][y] + reserved[x][y]:
            seat[x][y+1] = seat[x][y] + reserved[x][y]
            q.append((x, y+1))
        if 0 <= x < n and 0 <= y-1 < n and seat[x][y-1] > seat[x][y] + reserved[x][y]:
            seat[x][y-1] = seat[x][y] + reserved[x][y]
            q.append((x, y-1))


print(ans)
### BUGGY CODE ###

n = int(input())

s = input()

x = []

for i in range(n):
    x.append(s[i])

import itertools

cnt = 0
for i in range(1,n+1):
    p = list(itertools.combinations(s,i))

    for pp in p:
        if len(pp) == len(set(pp)):
            cnt = cnt + 1

print(cnt)


### FIXED CODE ###


n = int(input())

s = input()

x = []

for i in range(n):
    x.append(s[i])

import collections

clist = collections.Counter(x)

y = list(clist.values())

cnt = 1

for item in y:
    cnt = cnt * (item + 1)

cnt = cnt - 1
cnt = cnt % (10 ** 9 + 7)
print(cnt)
### BUGGY CODE ###

from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    S = input().rstrip("\n")
    dp = [[0 for i in range(13)] for i in range(len(S)+1)]
    dp [0][0] = 1
    for i in range(1,len(S)+1):
        modi = (10**(i-1)) %13
        s = S[len(S)-i]
        if s!= '?':
            mod_q = (int(s)*modi)%13
            for k in range(13):
                dp[i][(k+mod_q) % 13] = (dp[i][(k+mod_q) % 13]+dp[i-1][k]) % DIV
        else:
            for j in range(10):
                mod_q = (j*modi) % 13
                for k in range(13):
                    dp[i][(k+mod_q) % 13] = (dp[i]
                                             [(k+mod_q) % 13]+dp[i-1][k]) % DIV
    return dp[len(S)][5]
print(main())


### FIXED CODE ###

from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    S = input().rstrip("\n")
    dp = [[0 for i in range(13)] for i in range(len(S)+1)]
    dp [0][0] = 1
    modi = 1%13
    for i in range(1,len(S)+1):
        
        s = S[len(S)-i]
        if s!= '?':
            mod_q = (int(s)*modi)%13
            for k in range(13):
                dp[i][(k+mod_q) % 13] = (dp[i][(k+mod_q) % 13]+dp[i-1][k]) % DIV
        else:
            for j in range(10):
                mod_q = (j*modi) % 13
                for k in range(13):
                    dp[i][(k+mod_q) % 13] = (dp[i]
                                             [(k+mod_q) % 13]+dp[i-1][k]) % DIV
        modi = (modi*10)%13
    return dp[len(S)][5]
print(main())
### BUGGY CODE ###

N, X, Y = [int(i) for i in input().split()]
gp = [[float('inf')]*N for _ in range(N)]

def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



for i in range(N-1):
    gp[i][i+1] = 1
    gp[i+1][i] = 1
    if(i==X-1):
        gp[i][Y-1] = 1
        gp[Y-1][i] = 1

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

for i in li:
    print(i)



### FIXED CODE ###

N, X, Y = [int(i) for i in input().split()]
li = [0]*(N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        k = 0
        if(i<X and j<X):
            k = j-i
        if(i<X and X<=j<=Y):
            k = min(j-i, X-i+1+Y-j)
        if(i<X and Y<j):
            k = X-i+1+j-Y
        if(X<=i<=Y and X<=j<=Y):
            k = min(j-i, i-X+1+Y-j)
        if(X<=i<=Y and Y<j):
            k = min(j-i, i-X+1+j-Y)
        if(Y<i and Y<j):
            k = j-i
        li[k-1] += 1

for i in li:
    print(i)
### BUGGY CODE ###

def biggerthanB(x,C):
    for i in range(len(C)):
        if x < C[i]:
            return len(C) - i 
    return 0

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

numpattern = 0
for a in range(N):
    for b in range(N):
        if B[b] > A[a]:
            numpattern += biggerthanB(B[b],C)
            #print(A[a],B[b],numpattern)

print(numpattern)

### FIXED CODE ###

import bisect

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

numpattern = 0

for i in range(N):
    numsmallerA = bisect.bisect_left(A,B[i])
    numbiggerC = N - bisect.bisect_right(C,B[i])
    numpattern += numsmallerA * numbiggerC

print(numpattern)
### BUGGY CODE ###

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

# In[14]:


from collections import deque


# In[15]:


S = deque(input())
Q = int(input())
for _ in range(Q):
    q = list(input().split())
    if len(q) == 1:
        S = deque(reversed(S))
    else:
        if q[1] == "1":
            S.appendleft(q[2])
        else:
            S.append(q[2])
print("".join(S))


# In[ ]:






### FIXED CODE ###

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

# In[14]:


from collections import deque


# In[21]:


S = deque(input())
Q = int(input())
rev_cnt = 0
for _ in range(Q):
    q = input().split()
    if len(q) == 1:
        rev_cnt += 1
    else:
        if (rev_cnt+int(q[1]))%2 == 0:
            S.append(q[2])
        else:
            S.appendleft(q[2])
if rev_cnt%2 == 0:
    print("".join(S))
else:
    print("".join(list(reversed(S))))    


# In[ ]:
### BUGGY CODE ###

n=int(input())
s=input()

ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            x,y,z=s[i],s[j],s[k]
            if x!=y and y!=z and z!=x and j-i!=k-j:
                ans+=1
print(ans)

### FIXED CODE ###

from itertools import*
n=int(input())
s=input()

*x,=accumulate(i=="R" for i in s)
*y,=accumulate(i=="G" for i in s)
*z,=accumulate(i=="B" for i in s)
x2=list(accumulate(i=="R" for i in s[::-1]))[::-1]
y2=list(accumulate(i=="G" for i in s[::-1]))[::-1]
z2=list(accumulate(i=="B" for i in s[::-1]))[::-1]

ans=0
if n<4:
    print(0)
else:
    for i in range(1,n-1):
        p=s[i]
        for j in range(1,min(i,n-i-1)+1):
            q,r=s[i-j],s[i+j]
            ans-=(p!=q and q!=r and r!=p)
                
    
    for i in range(1,n-1):
        if s[i]=="R":
            ans+=y[i-1]*z2[i+1]
            ans+=z[i-1]*y2[i+1]
        elif s[i]=="G":
            ans+=x[i-1]*z2[i+1]
            ans+=z[i-1]*x2[i+1]
        elif s[i]=="B":
            ans+=x[i-1]*y2[i+1]
            ans+=y[i-1]*x2[i+1]
    print(ans)
### BUGGY CODE ###

# gacha

n = int(input())
ln = []
for i in (range(n)):
    stn = input()
    if stn in ln:
        pass
    else:
        ln.append(stn)
print(len(ln))

### FIXED CODE ###

# gacha

n = int(input())
ln = set()
for i in (range(n)):
    stn = input()
    if stn in ln:
        pass
    else:
        ln.add(stn)
print(len(ln))
### BUGGY CODE ###

S = list(input())
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
a = 0
for i in query:
    if i[0] == '1':
        if a == 0:
            a = 1
        else:
            a = 0
    elif i[0] == '2':
        if i[1] == '1':
            if a == 1:
                S.append(i[2])
            else:
                S.insert(0, i[2])
        elif i[1] == '2':
            if a == 1:
                S.insert(0, i[2])
            else:
                S.append(i[2])
if a == 1:
    S.reverse()
print(''.join(S))


### FIXED CODE ###

S = list(input())
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
a = 0
mem = []
for i in query:
    if i[0] == '1':
        if a == 0:
            a = 1
        else:
            a = 0
    elif i[0] == '2':
        if i[1] == '1':
            if a == 1:
                S.append(i[2])
            else:
                #S.insert(0, i[2])
                mem.append(i[2])
        elif i[1] == '2':
            if a == 1:
                #S.insert(0, i[2])
                mem.append(i[2])
            else:
                S.append(i[2])
mem.reverse()
S[0:0] = mem
if a == 1:
    S.reverse()
# print(S)
print(''.join(S))
### BUGGY CODE ###

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k:return 0
  if n==0 or k==0:return 1
  a=factorial(n)%p
  b=factorial(k)%p
  c=factorial(n-k)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d*d)%p
  if b%2==1:
    return (a*power_func(a,b-1,p))%p
import copy
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
b=copy.deepcopy(a)
b.sort()
tmp=-1
for i in range(n):
  if b[i]==b[i+1]:
    tmp=b[i]
r=[]
for i in range(n+1):
  if a[i]==tmp:
    r.append(i)
y=abs(r[1]-r[0]-1)
for k in range(1,n+2):
  ans=(comb(n-1,k,mod)+comb(n-1,k-2,mod)+comb(n-1,k-1,mod)*2-comb(n-1-y,k-1,mod))%mod
  print(ans)

### FIXED CODE ###

def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
n=int(input())
mod=10**9+7
for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
import copy
a=list(map(int,input().split()))
b=copy.deepcopy(a)
b.sort()
tmp=-1
for i in range(n):
  if b[i]==b[i+1]:
    tmp=b[i]
r=[]
for i in range(n+1):
  if a[i]==tmp:
    r.append(i)
y=abs(r[1]-r[0]-1)
for k in range(1,n+2):
  ans=(comb(n-1,k,mod)+comb(n-1,k-2,mod)+comb(n-1,k-1,mod)*2-comb(n-1-y,k-1,mod))%mod
  print(ans)
### BUGGY CODE ###

import numpy as np
import heapq
inf = 10**5
h, w = map(int, input().split())
wall = 0
grid = []
for _ in range(h):
    inp = input()
    wall += inp.count("#")
    grid.append([1 if i == "." else inf for i in inp])
grid = np.array(grid)
cost = np.ones(grid.shape, dtype=int)*inf

todo = [(0, 0)]     #cost, node
heapq.heapify(todo)
seen = np.zeros(grid.shape, dtype=int)

d = ((1, 0),
     (0, 1),
     (-1, 0),
     (0, -1))

while todo:
    c, n = heapq.heappop(todo)
    ny = n//w
    nx = n%w
    seen[ny][nx] = 1
    cost[ny][nx] = c

    for dx, dy in d:
        x, y =dx+nx, dy+ny
        if 0 <= x and x < w and 0 <= y and y < h and seen[y][x] == 0:
            cn = (min(cost[y][x], c+grid[y][x]), x+w*y)
            heapq.heappush(todo, cn)

if cost[-1][-1] >= inf:
    ans = -1
else:
    ans = h*w - (cost[-1][-1]+1) - wall
print(ans)

### FIXED CODE ###

import numpy as np
from collections import deque
h, w = map(int, input().split())

inf = 1009
grid = np.zeros((h + 2, w + 2), dtype=int)
for i in range(h):
    grid[i + 1][1:-1] = np.array([1 if j == "." else 0 for j in input()])
white = grid.sum()

cost = np.ones((h+2, w+2), dtype=int)*inf
cost[1][1] = 1

d = ((1, 0), (0, 1), (-1, 0), (0, -1))
to = deque([(1, 1)])
while to:
    x, y = to.popleft()
    c = cost[x][y]
    for xi, yi in d:
        nx = x + xi
        ny = y + yi
        if not grid[nx][ny]:
            continue
        to.append((nx, ny))
        cost[nx][ny] = min(cost[nx][ny], c+1)
        grid[nx][ny] = 0

if cost[-2][-2] == inf:
    ans = -1
else:
    ans = white-cost[-2][-2]
print(ans)
### BUGGY CODE ###

import bisect
def prime(n):
    seq = list(range(2, n))
    while len(seq) > 0:
        prime = seq.pop(0)
        yield prime
        # 素数で割り切れない数字のリストを作成
        seq = [i for i in seq if not i % prime == 0]

q=int(input())
l = []
r = []
for i in range(q):
    x,y = map(int,input().split())
    l.append(x)
    r.append(y)
ww = max(r)
a = list(prime(ww+1))

#print('a',a)

ans = [0]
for i in range(2,ww+1):
    if i in a:
        if (i+1)/2 in a:
            ans.append(ans[-1]+1)
        else:
            ans.append(ans[-1])
    else:
        ans.append(ans[-1])

#print(ans)

for i in range(0,q):
    if l[i] == 1:
        print(ans[r[i]-1])
    else:
        print(ans[r[i]-1]-ans[l[i]-2])

### FIXED CODE ###

import math
 
Q = int(input())
 
# 素数表
n = 100000
P = [False] * n
P[2] = True
for i in range(3, n, 2):
    k = True
    for j in range(3, int(math.sqrt(i)) + 1, 2):
        if i % j == 0:
            k = False
            break
    if k:
        P[i] = True
 
# Nと(N+1)÷2が素数か否か
a = [0] * n
for i in range(1, n, 2):
    j = (i + 1) // 2
    if P[i] and P[j]:
        a[i] = 1
# 累積和
for i in range(n - 1):
    a[i + 1] += a[i]
 
for _ in range(Q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])
### BUGGY CODE ###

n,m = map(int,input().split())
s = str(input())
now = n
ans = ""
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans=str(num)+" "+ans
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
s = str(input())
now = n
ans = ""
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans=str(num)+" "+ans
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(ans)
### BUGGY CODE ###

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

bar = {}

for i in A:
    if A.count(i)>=2:
        bar[i] = A.count(i)

if len(bar)>=2:
    bar = sorted(bar.items(), reverse=True)
    print(bar[0][0]*bar[1][0])
else:
    print(0)

### FIXED CODE ###

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

A.sort(reverse = True)
a=0
b=0
cnt = 1
for i in range(1,len(A)):
    if A[i]==A[i-1]:
        cnt+=1
    else:
        cnt=1
        
    if cnt==2:
        if a==0:
            a=A[i]
        elif b==0:
            b=A[i]
        cnt=0
        
        if a*b!=0:
            break

print(a*b)