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

import sys
import fractions
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt=0
b=[ans//a[i] for i in range(n)]
print(sum(b)%mod)


### FIXED CODE ###

import sys
from collections import deque
import heapq
import math
import bisect
from itertools import permutations
from itertools import accumulate
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

dic={}
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# print(factorization(12))
for i in range(n):
    tmp=factorization(a[i])
    for j in range(len(tmp)):
        if not tmp[j][0] in dic:
            dic[tmp[j][0]]=tmp[j][1]
        else:
            dic[tmp[j][0]]=max(dic[tmp[j][0]],tmp[j][1])
l=1
for i in dic.keys():
    l*=i**dic[i]
    l%=mod
# print(l)
ans=0
for i in range(n):
    ans+=l*pow(a[i],mod-2,mod)
    ans%=mod
print(ans)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

b = sorted(a,reverse=True)

if b[0] == b[1]:
    for i in range(n):
        print(b[0])
else:
    s = max(a)
    for i in range(n):
        if i == a.index(s):
            print(b[1])
        else:
            print(s)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
s = max(a)
l = a.index(max(a))
a[l] = 0
t = max(a)

for i in range(n):
    if i == l:
        print(t)
    else:
        print(s)
### BUGGY CODE ###

#input
n, a, b = map(int, input().split())

#output
mod = pow(10, 9) + 7

def cmb(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= (n-i) % mod
        fac *= (i+1) % mod
    return res*pow(fac, mod-2, mod) % mod

answer = (pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)) % mod
print(answer)

### FIXED CODE ###

#input
n, a, b = map(int, input().split())

#output
mod = pow(10, 9) + 7

def cmb(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    k = min(n-k,k)
    value = 1
    inv = [1] * (k+1)
    if k >= 1:
        value *= (n-k+1) % mod
    for i in range(2,k+1):
        inv[i] = mod-inv[mod%i]*(mod//i)%mod
        value = value * (n-k+i) * inv[i] % mod
    return value

answer = (pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)) % mod
print(answer % mod)
### BUGGY CODE ###

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

ans = 1

for i in range(len(N)):
    ans *= N[i]

if ans > 10**18:
    print('-1')
else:
    print(ans)

### FIXED CODE ###

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

ans = 1

if 0 in N:
    ans = 0
else:
    for i in range(len(N)):
        ans *= N[i]
        if ans > 10**18:
            break

if ans > 10**18:
    print('-1')
else:
    print(ans)
### BUGGY CODE ###

import itertools
L,R = map(int,input().split())

l = L//2019
r = R//2019

if((l-r >= 1)or(L%2019 == 0)or(R%2019 == 0)):
  ans = 0
  
else:
 A = []
 ans = 2018
 judge = 0
 for i in range(L,R+1):
    i = i%2019
    if(i%673 == 0): judge += 673
    if(i%3 == 0): judge += 3 
    A.append(i)

 if(judge == 673+3): #3, 673(mod 2019) あり
   ans = 0
 else: #len(A) <673 (なぜならば0~672 or 673 ~ 1346 or ...)
   A_comb = list(itertools.combinations(A,2))
   for i in range(len(A_comb)):
     tmp = list(A_comb[i])
     ans = min(ans,(tmp[0]*tmp[1])%2019)
 
print(ans)

### FIXED CODE ###

import itertools
L,R = map(int,input().split())

l = L//2019
r = R//2019

if((r-l >= 1)or(L%2019 == 0)or(R%2019 == 0)):
  ans = 0
  
else:
 A = []
 ans = 2018
 judge = 0
 for i in range(L,R+1):
    i = i%2019
    if(i%673 == 0): judge += 673
    if(i%3 == 0): judge += 3 
    A.append(i)

 if(judge == 673+3): #3, 673(mod 2019) あり
   ans = 0
 else: #len(A) <673 (なぜならば0~672 or 673 ~ 1346 or ...)
   A_comb = list(itertools.combinations(A,2))
   for i in range(len(A_comb)):
     tmp = list(A_comb[i])
     ans = min(ans,(tmp[0]*tmp[1])%2019)
 
print(ans)
### BUGGY CODE ###

from collections import deque
from bisect import bisect_left

N, K, C = map(int, input().split())
S = input()

first = deque()
pre = -C - 1
for i, s in enumerate(S):
  if i > pre + C and s == 'o':
    first.append(i)
    pre = i
    if len(first) == K:
      break
firstset = set(first)

last = deque()
pre = -C - 1
for i, s in enumerate(S[::-1]):
  if i > pre + C and s == 'o':
    last.appendleft(N - 1 - i)
    pre = i
    if len(last) == K:
      break
lastset = set(last)

for i, s in enumerate(S):
  if s == 'o':
    if i not in firstset or i not in lastset:
      continue
    if bisect_left(first, i) <= bisect_left(last, i):
      print(i + 1)

### FIXED CODE ###

from collections import deque

N, K, C = map(int, input().split())
S = input()

last = deque()
pre = -C - 1
for i, s in enumerate(reversed(S)):
  if i > pre + C and s == 'o':
    last.appendleft(N - 1 - i)
    pre = i
    if len(last) == K:
      break

count = 0
pre = -C - 1
x = last.popleft()
for i, s in enumerate(S):
  if i > pre + C and s == 'o':
    count += 1
    while x < i:
      x = last.popleft()
    if x == i and count + len(last) == K:
      print(i + 1)
    pre = i
    if count == K:
      break
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q):
    lr.append(list(map(int, input().split())))

for idx in lr:
    sub = S[idx[0] - 1:idx[1]]
    cnt = sub.count("AC")
#    print("cnt = {}, sub = {}".format(cnt, sub))
    print(str(cnt))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q):
    lr.append(list(map(int, input().split())))

ACnum = [0]
for i in range(N - 1):
    ACnum.append(ACnum[-1])
    if("AC" == S[i:i + 2]):
        ACnum[i + 1] += 1
#print("ACnum = {}".format(ACnum))

for l, r in lr:
    print(str(ACnum[r - 1] - ACnum[l - 1]))
### BUGGY CODE ###

N,x = map(int,input().split())
DP = [list(map(int,input().split()))]+[[float('inf')]*(N) for i in range(N-1)]
for i in range(N-1):
    for j in range(N):
        DP[i+1][j] = min(DP[i][j-1],DP[i][j])
ans = float('inf')
for i in range(N):
    ans = min(ans,sum(DP[i])+i*x)
print(ans)

### FIXED CODE ###

N,x = map(int,input().split())
DP = [list(map(int,input().split()))]+[[float('inf')]*(N) for i in range(N-1)]
for i in range(N-1):
    for j in range(N):
        DP[i+1][j] = min(DP[i][j-1],DP[i][j])
ans = float('inf')
for i in range(N):
    ans = min(ans,sum(DP[i])+i*x)
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort(reverse=True)
for i in range(m):
    x=lst.index(max(lst))
    lst[x]=int(lst[x]/2)
print(sum(lst))    

### FIXED CODE ###

import heapq
import math
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))
   
    
    
print(-1*sum(a))
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    ans = 1
    for i in a:
        ans *= i
    INF = int(1e18)
    if ans > INF: 
        print(-1)
        return
    print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    for i in a:
        if i == 0:
            print(0)
            return
    ans = 1
    INF = int(1e18)
    for i in a:
        ans *= i
        if ans > INF:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    hist = [0] * 2*pow(10, 5)
    for a in A:
        hist[a-1] += 1

    all = 0
    for h in hist:
        if h >= 2:
            all += combinations_count(h, 2)

    for a in A:
        h = hist[a-1]
        if h > 2:
            diff = combinations_count(h, 2) - combinations_count(h-1, 2)
            print(all - diff)
        elif h == 2:
            print(all - 1)
        else:
            print(all)
    
if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import math

def combinations_count(n):
    return math.floor(n*(n-1)/2)

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    hist = [0] * 2*pow(10, 5)
    for a in A:
        hist[a-1] += 1

    all = 0
    for h in hist:
        if h >= 2:
            all += combinations_count(h)

    for a in A:
        h = hist[a-1]
        if h >= 2:
            diff = h-1
            print(all - diff)
        else:
            print(all)
    
if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

N,K = map(int, input().split())
*P, = map(int, input().split())
S   = [0]*(N+1)


for i in range(N):
    S[i+1] = S[i] + P[i]

right = 0
left  = 0
ans   = 0
for i in range(N-K+1):

    if ans <= (S[i+K]-S[i]):
        ans = (S[i+K]-S[i])
        right = i+K
        left  = i

ans = 0
for j in range(left, right, 1):
    ans = ans + sum(list(range(1,P[j]+1,1)))/(P[j])
print(ans)

### FIXED CODE ###

N,K = map(int, input().split())
*P, = map(int, input().split())
S   = [0]*(N+1)


for i in range(N):
    S[i+1] = S[i] + P[i]

right = 0
left  = 0
ans   = 0
for i in range(N-K+1):

    if ans <= (S[i+K]-S[i]):
        ans = (S[i+K]-S[i])
        right = i+K
        left  = i

ans = 0
for j in range(left, right, 1):
    ans = ans + (1+P[j])
print(ans/2)
### BUGGY CODE ###

from itertools import accumulate
from collections import Counter, defaultdict
import copy
n,k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + list(accumulate([(i-1) % k for i in a]))
a = [i % k for i in a]
ans = 0
start = defaultdict(int)
start[0] += 1
maps = [start]
for i in a[1:]:
  now = maps[-1].copy()
  now[i] += 1
  maps.append(now)
for i in range(n):
  v = a[i]
  ans += maps[min(n,i+k-1)][v]-maps[i][v]
print(ans)

### FIXED CODE ###

from itertools import accumulate
from collections import defaultdict
import bisect

n,k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + list(accumulate([(i-1) % k for i in a]))
a = [i % k for i in a]
ans = 0
maps = defaultdict(list)
for k1,v in enumerate(a):
  maps[v].append(k1)
for i in range(n):
  v = a[i]
  ans += bisect.bisect_right(maps[v],i+k-1) - bisect.bisect_right(maps[v],i)
print(ans)
### BUGGY CODE ###

from bisect import bisect_left
from collections import deque

def main():
    inf=float("inf")
    sm=1
    n=int(input())
    alst=[inf]*n
    work=[inf]*n
    index_list=[inf]*n
    for i in range(n):
        a=int(input())
        alst[i]=a
        j=bisect_left(work,a)
        work[j]=a
        index_list[j]=i
    alst=[x for i,x in enumerate(alst) if not i in index_list]

    while alst:
        sm+=1
        n=len(alst)
        work=[inf]*n
        index_list=[inf]*n
        for i in range(n):
            a=alst[i]
            j=bisect_left(work,a)
            work[j]=a
            index_list[j]=i
        alst=[x for i,x in enumerate(alst) if not i in index_list]
    print(sm)

main()

### FIXED CODE ###

from bisect import bisect_right

def main():
    inf=float("inf")
    n=int(input())
    alst=[int(input()) for _ in range(n)]
    work=[inf]*n
    for i in range(n-1,-1,-1):
        j=bisect_right(work,alst[i])
        work[j]=alst[i]
    print(n-work.count(inf))

main()
### BUGGY CODE ###

from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

A_count=[A.count(A_s[x]) for x in range(len(A_s))]
# for x in range(len(A_s)):
#   i=A.count(A_s[x])
#   A_count.append(i)



for i in A_count:
  if 2<=i:
    cnt+=(i*(i-1))//2



[print(cnt) if A_count[A_s.index(A[i])]==1 else print(cnt-A_count[A_s.index(A[i])]+1) for i in range(N)]

# for i in range(N):
#   x=A_count[A_s.index(A[i])]
#   if x==1:
#     print(cnt)
#   else:
#     print(cnt-x+1)

### FIXED CODE ###

import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)
### BUGGY CODE ###

s = input()
mod = 10 ** 9 + 7
dp = []
for i in range(13):
    temp = [0] * len(s)
    dp.append(temp)
amari_list = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]
for i in range(len(s)):
    amari_list.append([10 * amari_list[-1][i] for i in range(10)])
# j桁目がxのとき13で割ったあまり
def amari(x, j):
    if x != "?":
        x = int(x)
        return [amari_list[j][x]]
    else:
        return amari_list[j]
for i in amari(s[-1], 0):
    dp[i][0] = 1
for i in range(1, len(s)):
    for j in range(13):
        for k in amari(s[-i-1], i):
            dp[j][i] += dp[(j - k) % 13][i - 1]
            dp[j][i] %= mod
print(dp[5][len(s) - 1])

### FIXED CODE ###

s = input()
n = len(s)
mod = 10 ** 9 + 7
amari = [1]
for i in range(n - 1):
    amari.append(amari[-1] * 10 % 13)
amari.reverse()
dp = [[0 for i in range(13)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            temp = 0
            for k in range(10):
                temp += dp[i][(j - amari[i] * k) % 13]
                temp %= mod
            dp[i + 1][j] = temp
        else:
            num = int(s[i])
            dp[i + 1][j] = dp[i][(j - amari[i] * num) % 13]
print(dp[n][5])
### BUGGY CODE ###

import scipy as sp
import numpy as np
import math
 
 
N = int(input())
 
ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        d = sp.gcd(a, b)
        for c in range(1, N+1):
 
            ans += sp.gcd(c, d)
 
print(ans)

### FIXED CODE ###

import scipy as sp
import numpy as np
import math


N = int(input())

ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        d = math.gcd(a, b)
        for c in range(1, N+1):

            ans += math.gcd(c, d)

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

n = int(input())
a = list(map(int, input().split()))
res = 1
for i in a:
    if (i == 0):
        res = 0
        break
    res = res * i
    
if(res > 10**18):
    print(-1)
else:
    print(res)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
res = 1
if(0 in a):
    print(0)
else:
    for i in a:
        res = res * i
        if(res > 10**18):
            res = -1
            break
    print(res)
### BUGGY CODE ###

A,B = map(int,input().split())
greater = max(A,B)
lcm = 0
while(True):
    if((greater % A == 0) and (greater % B == 0)):
        lcm = greater
        break
    greater += 1
print(greater)

### FIXED CODE ###

A,B = map(int,input().split())
def gcd(A,B):
    temp = A % B
    while temp != 0:
        A = B
        B = temp
        temp = A%B
    return B
print(int(A*B/gcd(A,B)))
### BUGGY CODE ###

n = int(input())

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

l.sort()

m = int(input())

for i in range(m):
    a,b = map(int, input().split())
    
    l = [b if j == a else j for j in l]

    print(sum(l))

### FIXED CODE ###

import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr: #あらかじめ各Aiの個数を数えておく
 cnt[val]+=1
sums=sum(arr) #あらかじめAiの総和を求めておく
q=int(input())
for _ in range(q):
 b,c=map(int,input().split())
 diff=(c-b)*(cnt[b]) #各クエリにおいて数列Aの総和は(値がBiである要素の個数)*(Ci-Bi)だけ変化する
 sums+=diff
 print(sums) 
 cnt[c]+=cnt[b] #値がCi,Biである要素の個数を更新する
 cnt[b]=0
### BUGGY CODE ###

N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

maxdiff = 0
ct = 0

for i in range(N):
    for j in range(i+1,N):
        if A[j]-A[i] > maxdiff:
            maxdiff = A[j]-A[i]
            ct = 1
        elif A[j]-A[i] == maxdiff:
            ct += 1

print(ct)

### FIXED CODE ###

N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

maxdiff = 0
ct = 0
mintmp = float("inf")
for A_i in A:
    mintmp = min(A_i,mintmp)
    diff = A_i - mintmp
    if diff > maxdiff:
        maxdiff = diff
        ct = 1
    elif diff == maxdiff:
        ct += 1
print(ct)
### BUGGY CODE ###

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

import sys


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


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))

    ans = 1

    for i in a_list:
        ans *= i

    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    resolve()



### FIXED CODE ###

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

import sys


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


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))
    flag = False
    try:
        if a_list.index(0):
            flag = True
            print(0)
            exit()
    except:
        if flag:
            exit()
        ans = 1
        for i in a_list:
            ans *= i

            if ans > 10 ** 18:
                print(-1)
                exit()

        print(ans)



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

string = str(input())         
n = 0
limit = len(string)-4
secondLimit = len(string)
size = len(string)-1
potencys = list()
potencys.append(1)
for i in range(size, 2, -1):
  intValue = int(string[i])
  potencyIndex = 0
  for j in range(i-1, -1, -1):
    potencyIndex += 1
    if potencyIndex >= len(potencys):
      potencys.append(potencys[-1]*10)
    intValue += int(string[j])* potencys[potencyIndex]
    if i-j > 2 and intValue % 673 == 0:
      n += 1
print(n)

### FIXED CODE ###

number = str(input())[::-1]
remainderDictionary = {0: 1}
    
sum = 0
x = 1
for i in number:
  x = (x * 10) % 2019
  sum += int(i) * x
  sum %= 2019
  remainderValue = remainderDictionary.get(sum,0) + 1
  remainderDictionary[sum] = remainderValue
     
ans = 0
for i in remainderDictionary:
  value = remainderDictionary[i]
  ans += value * (value - 1) // 2 # N C 2
print(ans)
### BUGGY CODE ###

#! /usr/bin/env python3

n, k = map(int, input().split())
M = [[(7*i+j-7)%11 for j in range(1, 7+1)] for i in range(1, n+1)]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(n-2, 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
for i in range(n-2):
    cnt += h[i%11]
print(cnt)

### FIXED CODE ###

#! /usr/bin/env python3

n, k = map(int, input().split())
M = [[7*i+j-7 for j in range(1, 7+1)] for i in range(1, min(n+1, 14))]
cnt = 0
f = lambda i, j : sum(M[i+y][j+x] for y in range(3) for x in range(3)) % 11 == k
h = [0] * 11
for i in range(min(max(0, n-2), 11)):
    for j in range(7-2):
        if f(i, j) :
            h[i] += 1
cnt = sum(h) * ((n-2) // 11)
for i in range((n-2) % 11):
    cnt += h[i]
print(cnt)
### BUGGY CODE ###

N = int(input())
l = list(map(int,input().split()))
m = []

for i in range(1,N+1):
  m.append(l.index(i)+1)
  
print(*m)

### FIXED CODE ###

N = int(input())
l = list(map(int,input().split()))
m = [0]*N

for i in range(N):
  m[l[i]-1] = i+1
  
print(*m)
### BUGGY CODE ###

def gcdf(a,n):
#    print("a:",a)
    a0=a[0]
    ramin=10**9
    ramin0=20**9
    while ramin0!=ramin:
        ramin0=ramin
        for i in range(n):
            a[i]=a[i]%a0
            if a[i]==0:
                a[i]=a0
#            ra=a[i]%a0
#            print(i,a[i],a0,ramin)
            if ramin>a[i] and a[i]!=0:
                ramin=a[i]
        a0=min(a)
#        print("a:",a,ramin)
    return ramin


#n=2
#a=[1000000000, 1000000000]
#n=4
#a=[15, 18, 24, 36]
n=int(input())

a=[]
for i in map(int,input().split()):
    a.append(i)

#print(a)
if n==2:
    print(max(a))
else:
    gcdv=0
    a.sort()
    for i in range(n):
        acpy=list(a)
#        del acpy[i]
        gcdx=gcdf(acpy,n-1)
#        gcdx=gcdf(a,n-1)
#        gcdx=gcd(acpy)
#        gcdx=functools.reduce(gcd,acpy)
#        gcdx=functools.reduce(math.gcd,acpy)
        if gcdx>gcdv:
            gcdv=gcdx
        aa=a[0]
        del a[0]
        a.append(aa)
    print(gcdv)


### FIXED CODE ###

def gcdf(a):
    a.sort()
#    print("a2:",a)
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
#    print("a2:",a)
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

#n=8
#a=[746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#ans=[19]
#n=2
#a=[1000000000, 1000000000]
#n=5
#a=[15, 18, 24, 36, 81]
#n=3
#a=[7, 6, 8]
n=int(input())
a=[]
for i in map(int,input().split()):
    a.append(i)
if n==2:
    print(max(a))
elif n<2**10:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n**(1/2))
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)
### BUGGY CODE ###

a,b,c,d=map(int, input().split())
z= -1 * 10**9
for i in range(a,b+1):
    for j in range(c,d+1):
        p = (i * j)
        if p > z:
            z=p
print(z)

### FIXED CODE ###

a,b,c,d=map(int, input().split())
p=[0]*4
p[0] = a * c
p[1] = a * d
p[2] = b * c
p[3] = b * d
z = max(p)
print(z)
### BUGGY CODE ###


def main():
  from collections import deque
  from collections import defaultdict
  
  n = int(input())
  a = list(map(int, input().split()))
  
  d = defaultdict(int)
  e = defaultdict(int)
  
  for x in a:
    d[x] += 1
  
  for x in a:
    get = e.get(x)
    if get == None:
      g = d[x] - 1
      h = [v for k,v in d.items() if (k != x and v>=2)]
      h.append(g)
      i = list(map(func, h))
      ans = sum(i)
      e[x] = ans
      print(ans)
    else:
      print(get)
    


    
def func(x):
  if x < 2:
    return 0
  else:
    ans = x*(x-1)//2
    return ans 
      
 
if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
  from collections import defaultdict
  from collections import Counter
  
  n = int(input())
  a = list(map(int, input().split()))
  
  d = Counter(a)
  e = defaultdict(int)
  
  func = lambda x: x*(x-1)//2 if x>=2 else 0
  v = list(d.values())
  base = sum(list(map(func, v)))
  
  for k,v in d.items():
    if v<=1:
      e[k] = base - 0
    else:
      e[k] = base - ( v*(v-1)//2 - (v-1)*(v-2)//2 )
    
  p = [str(e[x])+'\n' for x in a]
  q = ''.join(p)
  print(q)
      
 
if __name__=='__main__':
    main()
### BUGGY CODE ###

N = int(raw_input())
Ali = map(int,raw_input().split())
Bli = map(int,raw_input().split())
Cli = map(int,raw_input().split())
co=0
for A in Ali:
    for B in Bli:
        if A < B:
            for C in Cli:
                if B < C:
                    co +=1 
print(co)


### FIXED CODE ###

import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)