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

def resolve():
    _ = input()
    an = map(int, input().split())

    ans = 1
    for a in an:
        ans *= a
    if ans > 10 ** 18:
        ans = -1
    print(ans)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

def resolve():
    _ = input()
    an = sorted(map(int, input().split()), reverse=True)

    ans = 1
    if an[-1] == 0:
        ans = 0
    else:
        for a in an:
            ans *= a
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
    
if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

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

loop_time = N - K + 1

l_s = 0
l_e = K
max_score = 0
for i in range(loop_time):
    test_list = p_list[l_s:l_e]
    test_e = 0
    for j in test_list:
        e = sum(range(1,j+1)) / j
        test_e = test_e + e
    if test_e > max_score:
        max_score = test_e
    l_s = l_s + 1
    l_e = l_e + 1

print(max_score)


### FIXED CODE ###

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

loop_time = N - K

l_s = 0
l_e = K
max_score = 0
test_score = 0
# initial process
ans_list = p_list[l_s:l_e]
for j in ans_list:
    max_score += sum(range(1,j+1)) / j
    test_score = max_score
l_s = l_s + 1

for i in range(loop_time):
    # pop process
    pop_e = p_list[l_s-1]
    test_score = test_score - sum(range(1,pop_e+1)) / pop_e
    # push process
    push_e = p_list[l_e]
    test_score = test_score + sum(range(1,push_e+1)) / push_e
    if test_score > max_score:
        max_score = test_score
    l_s = l_s + 1
    l_e = l_e + 1

print(max_score)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import itertools

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

#list = []
#for i in range(N+1):
#    list.append(i)

#print(list)

#print(range(N+1))

ans=0

i=K
while(i<=N+1):
    #comb=combinationListRecursive(list, i)
    comb = list(itertools.combinations(range(N+1), i))
    #print(comb)
    tmp=[]
    for com in comb:
        sum=0
        for co in com:
            sum = sum+co
        if sum in tmp:
            continue
        else:
            tmp.append(sum)
            ans = ans+1
    i=i+1


print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

import itertools

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

#list = []
#for i in range(N+1):
#    list.append(i)

#print(list)

#print(range(N+1))

ans=0

i=K
while(i<=N+1):
    #print("i:"+str(i))
    #comb=combinationListRecursive(list, i)
    #comb = list(itertools.combinations(range(N+1), i))
    #print(comb)
    #tmp=[]
    #min=0
    #max=0
    #j=0
    #while(j<=i-1):
        #min = min+j
        #max = max+(N-j)
        #j=j+1
    max=((N-i+1+N)*i)/2
    min=((0+i-1)*i)/2
    #print("max:"+str(max))
    #print("min:"+str(min))
    #print("diff:"+str(max-min+1))
    ans=ans+(max-min)+1

    i=i+1


print(int(ans)%1000000007)
### BUGGY CODE ###

H, W = map(int, input().split())

G = []
for _ in range(H):
    g = []
    line = input()
    for i in range(W):
        g.append(line[i])
    G.append(g)

# 左に何マス行けるか
G_left = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W):
        if G[h][w] == "#":
            cnt = 0
            G_left[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_left[h][w] = cnt
# print(G_left)

# 右に何マス行けるか
G_right = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_right[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_right[h][w] = cnt
# print(G_right)

# 上に何マス行けるか
G_up = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H):
        if G[h][w] == "#":
            cnt = 0
            G_up[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_up[h][w] = cnt
# print(G_up)

# 下に何マス行けるか
G_down = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_down[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_down[h][w] = cnt
# print(G_down)
ans = 0
for h in range(H):
    for w in range(W):
        tmp = G_left[h][w] + G_right[h][w] + G_up[h][w] + G_down[h][w] - 3
        ans = max(ans, tmp)

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())

grid = []
for _ in range(H):
    line = input()
    # 後で都合が良いので末尾に足しておく
    line += "#"
    grid.append(line)

# 後で都合が良いので末尾に足しておく
grid.append("#" * W)
# print(grid)

G_h = []
for h in range(H):
    g = [-1] * W
    lamp_start = -1
    lamp = 0
    line = grid[h]
    for w in range(W):
        if line[w] == "#":
            g[w] = 0
        elif line[w] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = w
                # print("lampstart", w)
            if line[w + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, w + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_h.append(g)

# print(G_h)

G_v = []
for w in range(W):
    g = [-1] * H
    lamp_start = -1
    lamp = 0
    line = []
    for hi in range(H):
        line.append(grid[hi][w])
    line.append("#")
    # line = grid[w]
    for h in range(H):
        if line[h] == "#":
            g[h] = 0
        elif line[h] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = h
                # print("lampstart", w)
            if line[h + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, h + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_v.append(g)

# print(G_v)

ans = 0
for h in range(H):
    for w in range(W):
        tmp_ans = G_h[h][w] + G_v[w][h] - 1
        ans = max(ans, tmp_ans)
print(ans)
### BUGGY CODE ###

import itertools
r,g,b,n = map(int,input().split())
r_max,g_max,b_max = int(n/r),int(n/g),int(n/b)
ans = 0
for i,j,k in itertools.product(range(0,r_max+1),range(0,g_max+1),range(0,b_max+1)):
  if i*r+j*g+b*k == n:
    ans+=1  
print(ans)

### FIXED CODE ###

import itertools
r,g,b,n = map(int,input().split())
r_max,g_max,b_max = int(n/r),int(n/g),int(n/b)
ans = 0
for i,j in itertools.product(range(0,r_max+1),range(0,g_max+1)):
  if (n - (i*r+j*g))%b == 0 and n - (i*r+j*g) >= 0:
    ans+=1
print(ans)
### BUGGY CODE ###

N, K = list(map(int, input().split()))
 
h = []
for i in range(N):
    h.append(int(input()))
 
h_sort = sorted(h)

aa = h_sort[1:]
bb = h_sort[:-1]
diff = [a - b for a, b in zip(aa, bb)]

ans = []
for i in range(len(diff) - (K - 2)):
    tmp = 0
    for j in range(K - 1):
        tmp += diff[i + j]
    ans.append(tmp)
 
print(min(ans))


### FIXED CODE ###

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

h = []
for _ in range(N):
    h.append(int(input()))

h.sort()
minimum = h[N - 1]- h[0]

for i in range(N - K + 1):
    minimum = min(minimum, h[i + K - 1] - h[i])
print(minimum)
### BUGGY CODE ###

import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import deque
def resolve():
    m, n, k = map(int, input().split())
    si, sj, ti, tj = map(lambda x : int(x) - 1, input().split())
    grid = [input() for _ in range(m)]

    dist = [[INF] * n for _ in range(m)]
    dist[si][sj] = 0
    D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    queue = [(si, sj)]
    while queue:
        i, j = queue.pop()
        for di, dj in D:
            for s in range(1, k + 1):
                ni, nj = i + s * di, j + s * dj
                if not (0 <= ni < m and 0 <= nj < n):
                    break
                if grid[ni][nj] == '@':
                    break
                if dist[ni][nj] <= dist[i][j]:
                    break
                if dist[ni][nj] > dist[i][j] + 1:
                    dist[ni][nj] = dist[i][j] + 1
                    queue.append((ni, nj))

    ans = dist[ti][tj]
    if ans == INF:
        ans = -1
    print(ans)
resolve()

### FIXED CODE ###

import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import deque
def resolve():
    m, n, k = map(int, input().split())
    si, sj, ti, tj = map(lambda x : int(x) - 1, input().split())
    grid = [input() for _ in range(m)]

    dist = [[INF] * n for _ in range(m)]
    dist[si][sj] = 0
    D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    queue = deque([(si, sj)])
    while queue:
        i, j = queue.popleft()
        for di, dj in D:
            for s in range(1, k + 1):
                ni, nj = i + s * di, j + s * dj
                if not (0 <= ni < m and 0 <= nj < n):
                    break
                if grid[ni][nj] == '@':
                    break
                if dist[ni][nj] <= dist[i][j]:
                    break
                if dist[ni][nj] > dist[i][j] + 1:
                    dist[ni][nj] = dist[i][j] + 1
                    queue.append((ni, nj))

    ans = dist[ti][tj]
    if ans == INF:
        ans = -1
    print(ans)
resolve()
### BUGGY CODE ###

# -*- coding:utf-8 -*-

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

    # 他のAiにはあって、あるAiに唯一ない約数が答え
    
    candidates = []

    if N == 2:
        print(max(A[0], A[1]))
        return

    candidates = {}
    # まずは0番目の奴の候補を考える
    for i in range(1, A[0]+1):
        if A[0]%i == 0:
            candidates[i] = 1

    for key in candidates.keys():
        if A[1]%key != 0:
            candidates[key] -= 1

    for i in range(1, A[1]+1):
        if A[1]%i == 0:
            if not i in candidates:
                candidates[i] = 0

    import copy
    for i in range(2, N):
        copied_candidates = copy.deepcopy(candidates)
        for key in copied_candidates.keys():
            if A[i]%key == 0:
                pass
            else:
                candidates[key] -= 1
                if candidates[key] < 0:
                    candidates.pop(key)
    
    ans = 0
    for key in candidates.keys():
        ans = max(ans, key)
    
    print(ans)


    

if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
"""解説
GCD, DP, 累積和

「一つを選んで好きな数字に変えられる」とあるが、今回のケースでは「その数字を消す」と同じ。

すべてのGCDを試す

4 6 7 8 10 12 14

という数列が与えられたとき、

・4を消して、ほかの数字のGCDを計算

6 7 8 10 12 14

・6を消して、ほかの数字のGCDを計算

4 7 8 10 12 14

・7を消して、……

というのを全列挙するが、N=10**5なので、O(N**2)では計算が間に合わない。

なのでこれをもう少し高速でやりたい。

GCDは計算順序を問わない性質を利用する。

たとえば、8を消した場合

4 6 7 8 10 12 14
| 左 |× |   右  |

・左のGCD
・右のGCD
を計算し、GCD(左のGCD, 右のGCD)をやってもよい。

・左のGCDを考える
GCD(4) = L[1]
GCD(4 6) = L[2] = GCD(L[1], 6)
GCD(4 6 7) = L[3] = GCD(L[2], 7)
GCD(4 6 7 8) = L[4] = GCD(L[3], 8)
GCD(4 6 7 8 10) = L[5] = GCD(L[4], 10)

みたいな感じで計算できる。

・右のGCDについても同様に計算してやる。

この前計算ができたら、あとは累積和のように、どの数字を削除したときがGCDが最大になるのかを計算する。

"""
import copy

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

    def gcd(x, y):
        """ 最大公約数を求める """
        # x > y にしたい
        if y > x:
            x, y = y, x
        if y == 0:
            return x
        return gcd(x%y, y)

    # L[i] := A[i]が消されたときの左側のGCD
    L = [0]*(N+1)
    L[1] = A[0]
    for i in range(2, N):
        L[i] = gcd(L[i-1], A[i-1])

    # R[i] := A[i]が消されたときの右側のGCD
    R = [0]*(N+1)
    R[N-1] = 0
    R[N-2] = A[N-1]
    for i in range(N-3, -1, -1):
        R[i] = gcd(R[i+1], A[i+1])
    
    # 任意の数字を消したときの最大のGCDを求める
    ans = 0
    for i in range(N):
        tmp = gcd(L[i], R[i])
        ans = max(ans, tmp)

    print(ans)

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

N,A=map(int, input().split())
x=list(map(int, input().split()))
W=sum(x)
dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)]
for j in range(N+1):
    dp[j][0][0]=1
for j in range(1,N+1):
    xj=x[j-1]
    for k in range(1, N+1):
        for s in range(1, W+1):
            if s<xj:
                dp[j][k][s]=dp[j-1][k][s]
            else:
                dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-xj]

ans=0
for k in range(1,N+1):
    if k*A<=W:
        ans+=dp[N][k][k*A]
print(ans)


### FIXED CODE ###

import sys
from sys import stdin
input = stdin.readline

def solve(N, A, x):
    W=sum(x)
    dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)]
    for j in range(N+1):
        dp[j][0][0]=1
    for j in range(1,N+1):
        xj=x[j-1]
        for k in range(1, N+1):
            for s in range(1, W+1):
                if s<xj:
                    dp[j][k][s]=dp[j-1][k][s]
                else:
                    dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-xj]

    ans=0
    for k in range(1,N+1):
        if k*A<=W:
            ans+=dp[N][k][k*A]
        else:
            break
    return ans


def main(args):
    N,A=map(int, input().split())
    x=[int(x) for x in input().split()]
    ans=solve(N,A,x)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

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

while True:
    if m % h == 0:
        break
    h -= 1

print(h)

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

for d in make_divisors(m):
    if d <= h:
        ans = max(ans, d)

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

#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline
sys.setrecursionlimit(10**6)
########################################
mxn =  10**7
divs = [0]*(mxn + 11)
for i in range(1,mxn+1):
	for j in range(0, mxn+1,i):
		divs[j]+=1

n = int(input())
ans = 0
for i in range(1,n+1):
	ans+=i*divs[i]
print(ans)




### FIXED CODE ###

#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline
sys.setrecursionlimit(10**6)
########################################
mxn =  10**7
divs = [0]*(mxn + 11)
for i in range(1,mxn+1):
	for j in range(0, mxn+1,i):
		divs[j]+=1

n = int(input())
ans = 0
for i in range(1,n+1):
	ans+=i*divs[i]
print(ans)
### BUGGY CODE ###

L=int(input())
ans=0
tmp=0
#分割数
d=300
l=5
L_=int(L**(1/3))
for i in range(max(0,int(L_-l)*d),int(L_+l)*d):
  for j in range(max(0,int(L_-l)*d-i),int(L_+l)*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

### FIXED CODE ###

L=int(input())
print((L**3)/27)
### BUGGY CODE ###

import decimal
import math

N, K = map(int, input().split())
coin = [decimal.Decimal('0.5')**k for k in range(10**5)]
ans = 0
for i in range(1,N+1):
    x = 0
    while(True):
        if i*(2**x) >= K:
            ans += decimal.Decimal(1/N) * coin[x]
            break
        else: x += 1
   

print(ans)


### FIXED CODE ###

import math
N,K = map(int,input().split())
ans = 0
 
for i in range(1,N+1):
    if i >= K:
        ans += (1/N)
        continue
    X = int(math.log((K/i), 2))
    if (K/i) % 2**X == 0:
        pass
    else:
        X += 1
    ans += (1/N) * (1/2) ** X
print(ans)
### BUGGY CODE ###

n,k,s=map(int,input().split())
if s!=10**9:
    ans=""
    for i in range(k):
        ans+=str(s)+" "
    for j in range(n-k):
        ans+=str(s+1)+" "

else:
    ans=""
    for i in range(k):
        ans+=str(s)+" "
    for j in range(n-k):
        ans+=str(s-1)+" "


print(ans)


### FIXED CODE ###

n,k,s=map(int,input().split())
if s==10**9:
    ans=(str(s)+" ")*k+(str(1)+" ")*(n-k)


else:
    ans=(str(s)+" ")*k+(str(s+1)+" ")*(n-k)



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

h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[[0 for i in range(12881)] for j in range(w)] for k in range(h)]
for i in range(h):
  for j in range(w):
    for k in range(12801):
      t = grid[i][j]
      if i == j == 0 and t == k:
        dp[i][j][k] = 1
      if j > 0:
        dp[i][j][k] = dp[i][j][k] or dp[i][j-1][abs(k+t)] or dp[i][j-1][abs(k-t)]
      if i > 0:
        dp[i][j][k] = dp[i][j][k] or dp[i-1][j][abs(k+t)] or dp[i-1][j][abs(k-t)]
for i in range(12801):
  if dp[h-1][w-1][i] == 1:
    print(i)
    break


### FIXED CODE ###

h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[0 for j in range(w)] for k in range(h)]
buf = (h+w)*80
for i in range(h):
  for j in range(w):
      t = grid[i][j]
      if i == j == 0:
        dp[i][j] = 1 << buf+t | 1 << buf-t
      if j > 0:
        dp[i][j] = dp[i][j] | dp[i][j-1] << t | dp[i][j-1] >> t
      if i > 0:
        dp[i][j] = dp[i][j] | dp[i-1][j] << t | dp[i-1][j] >> t
for i in range(buf):
  if (dp[h-1][w-1] & 1 << buf+i) or (dp[h-1][w-1] & 1 << buf-i):
    print(i)
    exit()
### BUGGY CODE ###

from collections import Counter
n=int(input())
a=sorted(list(map(int,input().split())))
 
c=[1 for i in range(10**6+1)]
d = Counter(a)
s = list(set(a))
count = 0
for x in s:
  t = x * 2
  while t <= 10 ** 6:
    c[t] = 0
    t += x

for x in a:
  if d[x] == 1 and c[x] == 1:
    count += 1
print(count)

### FIXED CODE ###

from collections import Counter
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
 
c=[1 for i in range(10**6+1)]
d = Counter(a)
s = list(set(a))
count = 0
if d[1] == 1:
  print(1)
  sys.exit()
elif d[1] >=2:
  print(0)
  sys.exit()
for x in s:
  t = x * 2
  while t <= 10 ** 6:
    c[t] = 0
    t += x
 
for x in a:
  if d[x] == 1 and c[x] == 1:
    count += 1
print(count)
### BUGGY CODE ###

import math
from collections import defaultdict

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


def left_right(x, d):
    left = x - d - 0.5
    right = x + d + 0.5
    return left, right

printed = set()
printed_lst = []
bl = []
for x in range(K):
    dic = defaultdict(int)
    for i in range(N):
        l, r = left_right(i + 1, al[i])
        left = math.ceil(l)
        if left <= 0:
            left = 1
        right = math.floor(r)
        for n in range(left, right + 1):
            dic[n] += 1
    al = list(dic.values())[:N]
    bl = [str(i) for i in al]
    bls = ''.join(bl)
    #print(bls)
    printed.add(bls)
    printed_lst.append(bls)
    if len(printed) != len(printed_lst):
        print(bls)
        exit()

print(' '.join(bl))


### FIXED CODE ###

import math
from itertools import accumulate

N, K = map(int, input().split())
al = list(map(int, input().split()))
syusoku = [N] * N

for _ in range(K):
    s = [0] * N
    for i in range(N):
        left = i - al[i]
        right = i + al[i]
        if left < 0:
            left = 0
        s[left] += 1
        if right + 1 <= N - 1:
            s[right + 1] -= 1
        # print(left,right)
    al = list(accumulate(s))
    # print(al)
    if al == syusoku:
        print(*al)
        #print('end')
        exit()

print(*al)
### BUGGY CODE ###

from collections import deque

n, m, k = map(int, input().split())

friends = [[0] * n for _ in range(n)]

blocks = [[0] * n for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    friends[a-1][b-1] = 1
    friends[b-1][a-1] = 1

for i in range(k):
    c, d = map(int, input().split())
    blocks[c-1][d-1] = 1
    blocks[d-1][c-1] = 1

for i in range(n):
    q = deque()
    q.append(i)
    cnt = [-1] * n
    cnt[i] = 0
    total = 0
    while q:
        k = q.popleft()
        for j in range(n):
            if friends[k][j] and cnt[j] == -1:
                q.append(j)
                cnt[j] = cnt[k] + 1
                if cnt[j] > 1 and not blocks[i][j]:
                    total += 1
    print(total)

### FIXED CODE ###

from collections import deque

n, m, k = map(int, input().split())

#listを組むより早い
friends = [set() for _ in range(n)]
blocks = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    friends[a-1].add(b-1)
    friends[b-1].add(a-1)

for i in range(k):
    c, d = map(int, input().split())
    blocks[c-1].add(d-1)
    blocks[d-1].add(c-1)

q = deque()
ans = [0] * n
visited = [0] * n

for i in range(n):
    if visited[i]:
        continue
    #集合を構築していく
    group = {i}
    visited[i] = 1
    q.append(i)
    while q:
        k = q.popleft()
        for j in friends[k]:
            if not visited[j]:
                q.append(j)
                group.add(j)
                visited[j] = 1
    
    # できた集合内でとりあえず計算
    for l in group:
        ans[l] = len(group) - len(blocks[l] & group) - len(friends[l] & group) - 1
print(*ans)
#print(*ans,sep="\n")
### BUGGY CODE ###

# E - Flatten

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

modulus = 10 ** 9 + 7

class factorization:
    def __init__(self, x=1):
        self.vec = {}
        d = 2
        while d <= x:
            if x % d == 0:
                if d not in self.vec:
                    self.vec[d] = 0
                self.vec[d] += 1
                x //= d
            else:
                d += 1

    def add(self, x):
        for i in x.vec:
            self.vec[i] = max(self.vec[i] if i in self.vec else 0, x.vec[i])
        return self

    def subtract(self, x):
        for i in x.vec:
            self.vec[i] -= x.vec[i]
        return self

    def clone(self):
        x = factorization()
        for i in self.vec:
            x.vec[i] = self.vec[i]
        return x

    def value(self):
        p = 1
        for i in self.vec:
            p *= (i ** self.vec[i]) % modulus
        return p

fact = [factorization(x) for x in a]

lcm = factorization()
for f in fact:
    lcm.add(f)

difffact = [lcm.clone().subtract(f) for f in fact]

b = [f.value() for f in difffact]
s = sum(x % modulus for x in b) % modulus
print(s)


### FIXED CODE ###

# E - Flatten

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

modulus = 10 ** 9 + 7
binmod = (bin(modulus - 2))[2:]  # modulus - 2 in binary

MAX = 10 ** 6

primefact = [0 for i in range(MAX + 1)]

def sieve():
    # cf. https://www.geeksforgeeks.org/lcm-of-n-numbers-modulo-m/
    for i in range(2, MAX + 1):
        if primefact[i] == 0:
            for j in range(i, MAX + 1, i):
                if primefact[j] == 0:
                    primefact[j] = i

def factorize(x):
    if primefact[2] == 0:
        sieve()

    vec = {}
    while x >= 2:
        d = primefact[x]
        if d not in vec:
            vec[d] = 0
        vec[d] += 1
        x //= d
    return vec

def value(x):
    p = 1
    for i in x:
        p = (p * (i ** x[i])) % modulus
    return p

def inverse(x):
    p = 1
    for b in binmod:
        p = p * p % modulus
        if b == '1':
            p = p * x % modulus
    return p

def div(n, d):
    return n * inverse(d) % modulus

fact = [factorize(x) for x in a]

fset = set()
for f in fact:
    fset.update(f.keys())

l = {k: 0 for k in fset}
for f in fact:
    for k in f:
        l[k] = max(l[k], f[k])
lcm = value(l)

s = sum(div(lcm, x) for x in a) % modulus
print(s)