Harryxun/stf_run huggingface dataset:
n = int(input())
b = list(map(str, input().split()))
''.join(b)
ans = []
def dfs(b):
    if len(b) == 1:
        if int(b[0]) == 1:
            return True
    else:
        f = 0
        for j in range(len(b)):
            if int(b[j]) != i + 1:
                f = 1
                break
        if f == 0:
            for j in range(len(b)):
                ans.append(b[j])
            return True

        for i in range(len(b) - 1, -1, -1):
            if int(b[i]) == i + 1:
                if i == 0:
                    if dfs(b[1:]):
                        ans.append(i + 1)
                        return True
                else:
                    if dfs(b[:i] + b[i+1:]):
                        ans.append(i + 1)
                        return True
        return False
if dfs(b):
    ans.insert(0, 1)
    for i in range(len(ans)):
        print(ans[i])
else:
    print(-1)


### FIXED CODE ###

n = int(input())
b = list(map(int, input().split()))
ans = []
while(len(b) != 1):
    count = 0
    for i in range(len(b) - 1, -1, -1):
        if b[i] == i + 1:
            b.pop(i)
            ans.append(i + 1)
            count = 0
            break
        else:
            count += 1
    if count == len(b):
        print(-1)
        exit()
if b[0] == 1:
    ans.append(1)
    ans = list(reversed(ans))
    for i in range(len(ans)):
        print(ans[i])
else:
    print(-1)
s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i - 1
    while s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
        if j < 0:
            break
    j = i
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))


### FIXED CODE ###

s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i -1
    while j >= 0 and s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
    j = i
    if j == len(a) -1:
        return
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))
n = int(input())
d = {'AC':0,'WA':0,'TLE':0,'Re':0}
for j in range(n):
    i = input()
    d[i] += 1

for i in ['AC','WA','TLE','Re']:
    print('%s x %d' % (i, d[i]))

### FIXED CODE ###

n = int(input())
d = {'AC':0,'WA':0,'TLE':0,'RE':0}
for j in range(n):
    i = input()
    d[i] += 1

for i in ['AC','WA','TLE','RE']:
    print('%s x %d' % (i, d[i]))
hoge
fuga

### FIXED CODE ###

#!/usr/bin/env python3

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

def gcd(a, b):
    if a > b:
        a, b = b, a
    # assert(a <= b)
    if b%a == 0:
        return a
    else:
        return gcd(b%a, a)

def gcd_many(l):
    # if len(l) == 1:
    #     return l
    # elif len(l) == 2:
    #     return gcd(l[0], l[1])
    # else:
    #     return gcd(l[0], gcd_many(l[1:]))
    if len(l) == 1:
        return l[0]
    g = l[0]
    for i in range(1,len(l)):
        g = gcd(g, l[i])
    return g

Amax = max(A)
g = gcd_many(A)

possible = "POSSIBLE"
impossible = "IMPOSSIBLE"


if K > Amax:
    print(impossible)
else:
    if K % g == 0:
        print(possible)
    else:
        print(impossible)
# coding: utf-8
# Here your code !

S =[i+1 for i in xrange(13)]
H =[i+1 for i in xrange(13)]
C =[i+1 for i in xrange(13)]
D =[i+1 for i in xrange(13)]
#[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

n = input()
for i in xrange(n):
    c, a = raw_input().split()
    if c == "S":
        del S[int(a)-1]
    elif c == "H":
        del H[int(a)-1]        
    elif c == "C":
        del C[int(a)-1]        
    elif c == "D":
        del D[int(a)-1]

for i in xrange(len(S)):
    print "S " + str(S[i])
    
for i in xrange(len(H)):
    print "H " + str(H[i])    
    
for i in xrange(len(C)):
    print "C " + str(C[i])    
    
for i in xrange(len(D)):
    print "D " + str(D[i])    
    

### FIXED CODE ###

S =[i+1 for i in xrange(13)]
H =[i+1 for i in xrange(13)]
C =[i+1 for i in xrange(13)]
D =[i+1 for i in xrange(13)]
#[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

n = input()
for i in xrange(n):
    c, a = raw_input().split()
    if c == "S":
        for j in xrange(len(S)): 
            if S[j-1] == int(a):
             del S[j-1]
    elif c == "H":
        for j in xrange(len(H)): 
            if H[j-1] == int(a):
             del H[j-1]      
    elif c == "C":
        for j in xrange(len(C)): 
            if C[j-1] == int(a):
             del C[j-1]      
    elif c == "D":
        for j in xrange(len(D)): 
            if D[j-1] == int(a):
             del D[j-1]

for i in xrange(len(S)):
    print "S " + str(S[i])
    
for i in xrange(len(H)):
    print "H " + str(H[i])    
    
for i in xrange(len(C)):
    print "C " + str(C[i])    
    
for i in xrange(len(D)):
    print "D " + str(D[i])
a,b,c=input()split(",")
print(a,b,c)

### FIXED CODE ###

a,b,c=input().split(",")
print(a,b,c)
# cf16-finalA - Where's Snuke?
def main():
    h, w = list(map(int, input().rstrip().split()))
    A = [input().rstrip().split() for _ in range(h)]
    S = "ABCDEFGHIJ"
    for i in range(h):
        for j in range(w):
            if A[i][j] == "snuke":
                print(S[j], i + 1, sep="")
                return
    else:
        print(A)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# cf16-finalA - Where's Snuke?
from string import ascii_uppercase


def main():
    h, w = list(map(int, input().rstrip().split()))
    A = [input().rstrip().split() for _ in range(h)]
    S = ascii_uppercase
    for i in range(h):
        for j in range(w):
            if A[i][j] == "snuke":
                print(S[j], i + 1, sep="")
                return


if __name__ == "__main__":
    main()
import copy

N = int(input())
X = int(input(), 2)

def rev(num, i):
  i = N - 1 - i
  return num ^ (1 << i)



def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f



for i in range(N):
  n = rev(X, i)
  cnt = 0
  
  while n != 0:
    n = n % popcount(n)
    cnt += 1
  print(cnt)
  

      

### FIXED CODE ###

N = int(input())
X = input()

X_int = int(X, 2)
cnt1 = bin(X_int).count('1')
pcXi01 = cnt1 + 1
pcXi10 = cnt1 - 1
zero_idx = N + 5
if cnt1 == 1:
  for i in range(N):
    if X[i] == '1':
      zero_idx = i

if pcXi10 < 1:
  pcXi10 = 1
Xmod01 = X_int % pcXi01
Xmod10 = X_int % pcXi10

tmp01 = [1]
tmp10 = [-1]
for i in range(N - 1):
  tmp01.append(tmp01[i]*2 % pcXi01)
  tmp10.append(tmp10[i]*2 % pcXi10)

init_n = [0] * N
next_n = [0] * N
for i in range(N):
  if X[i] == '0':
    next_n[i] = (Xmod01 + tmp01[N - 1 - i]) % pcXi01
  else:
    next_n[i] = (Xmod10 + tmp10[N - 1 - i]) % pcXi10

for i in range(N):
  fn = 0
  if i == zero_idx:
    print(0)
    continue

  n = next_n[i]
  fn += 1
  while n != 0:
    n = n % bin(n).count('1')
    fn += 1
  
  print(fn)
x,t= map(int, input().split())
pritn(max(x-t,0))

### FIXED CODE ###

x,t= map(int, input().split())
print(max(x-t,0))
d = {"SUN":7,"MON":6,"TUE":5,"WEN":4,"THU":3,"FRI":2,"SAT":1}

s = input()
print(d[s])

### FIXED CODE ###

d = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}

s = input()
print(d[s])
list = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(list[input])


### FIXED CODE ###

num = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(num[input - 1])
N = int(input())
s1 = input()
s2 = input()
sum = 1
mul = 1
flag = 0
i = 0

while True:
    if i >= N:
        print(sum%1000000007)
        break

    elif s1[i]==s2[i] and flag==0:
        sum = 3
        i += 1
        flag = 1
    elif s1[i]!=s2[i] and flag==0:
        sum = 6
        i += 2
        flag = 2
    elif s1[i]==s2[i] and flag==1:
        mul = 2
        i += 1
        flag = 1
    elif s1[i]!=s2[i] and flag==1:
        mul = 2
        i += 2
        flag = 2
    elif s1[i]==s2[i] and flag==2:
        mul = 1
        i += 1
        flag = 1
    elif s1[i]!=s2[i] and flag==2:
        mul = 3
        i += 2
        flag = 2
    sum = sum*mul


### FIXED CODE ###

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

bars.sort(reverse=True)

flag = 0
l = 0
l1 = 0
l2 = 0

for x in bars:
    if flag==0:
        l = x
        flag = 1
    elif flag==1 and x==l and l1==0:
        l1 = x
        l = 0
        flag = 0
    elif flag==1 and x==l and l1!=0:
        l2 = x
        break
    else:
        l = x
        flag = 1

print(l1 * l2)
# -*- coding: utf-8 -*-
N = map(str, input().split())
out = "No"
N_list = list(N)
if N_list[0]==N_list[1] and N_list[0]==N_list[2]:
    out = "Yes"
elif N_list[1]==N_list[2] and N_list[1]==N_list[3]:
    out = "Yes"

print(out)


### FIXED CODE ###

# -*- coding: utf-8 -*-
N = str, input()
out = "No"
N_list = list(N[1])

if N_list[0]==N_list[1] and N_list[0]==N_list[2]:
    out = "Yes"
elif N_list[1]==N_list[2] and N_list[1]==N_list[3]:
    out = "Yes"

print(out)
[a,b,c] == [int(i) for i in input().split()]

if (a * b * c) % 2 == 0:
    print(0)
else:
    print(min(a * b,b * c,c * a))


### FIXED CODE ###

[a,b,c] = [int(i) for i in input().split()]

if (a * b * c) % 2 == 0:
    print(0)
else:
    print(min(a * b,b * c,c * a))
"""
制約
1≦N≦100
Nは整数
"""

#入力
n = int(input())

#九九リストの作成
list = []
for i in range(1, 10):
  for j in range(1, 10):
    list.append(i * j) #リストに追加　list.append()

#リスト内にNが存在するかどうかで判別＆出力
if N in list:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=int(input())

list=[]
for i in range(1,10):
  for j in range(1,10):
    list.append(i*j)
if N in list:
  print("Yes")
else:
  print("No")
def main():
    n, d = map(int, input().split())
    x = [int(input()) for i in range(n)]

    ans = 0
    for i in range(n-1):
        for j in range(i+1,n):
            res = 0
            for k in range(d):
                res += (x[j][k]-x[i][k])**2
            if (res**0.5).is_integer():
                ans += 1
    prnt(ans)

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for i in range(n)]

    ans = 0
    for i in range(n-1):
        for j in range(i+1,n):
            res = 0
            for k in range(d):
                res += (x[j][k]-x[i][k])**2
            if (res**0.5).is_integer():
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    lena = len(a)
    if (lena-k) % (k-1) == 0:
        print(((lena-k) // (k-1))+1)
    else :
        print(((lena-k) // (k-1))+2)
 resolve()

### FIXED CODE ###

def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    lena = len(a)
    if (lena-k) % (k-1) == 0:
        print(((lena-k) // (k-1))+1)
    else :
        print(((lena-k) // (k-1))+2)
resolve()
def is_circle(current_list, rest_list):
    if rest_list == []:
        if (current_list[-1] ^ current_list[0]) == current_list[1]:
            return True
        else:
            return False
    if len(current_list) == 1:
        for num in rest_list:
            current_list.append(num)
            rest_list.remove(num)
            if is_circle(current_list, rest_list):
                return True
        return False

    next_int = current_list[-1] ^ current_list[-2]
    if next_int in rest_list:
        current_list.append(next_int)
        rest_list.remove(next_int)
        return is_circle(current_list, rest_list)
    else:
        return False
        

n = int(input())
input_list = [int(i) for i in input().split(' ')]

if is_circle([input_list[0]], input_list[1:]):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import collections 

n = int(input())
input_list = [int(i) for i in input().split(' ')]

counter = collections.Counter(input_list)


unique_list = list(counter.keys())
counts = list(counter.values())

if (all(num == 0 for num in unique_list)):
    print('Yes')
else:
    if n % 3 == 0:
        zero_count = counter[0] 
        if zero_count == n / 3 and len(unique_list) == 2:
            print('Yes')
        else: 
            if len(unique_list) != 3:
                print('No')
            elif (unique_list[0] ^ unique_list[1] == unique_list[2]):
                if (all(counts[0] == num for num in counts)):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
    else:
        print('No')
a,b = map(int,input().split())
if a*b%2=0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

a,b = map(int,input().split())
if a*b%2==0:
  print('Even')
else:
  print('Odd')
list = raw_input().split()

A = int(list[0])

B = int(list[1])

c = int(list[2])

if B // A < C:
    print B // A

else:
    print C


### FIXED CODE ###

list = raw_input().split()

A = int(list[0])

B = int(list[1])

C = int(list[2])

if B // A < C:
    print B // A

else:
    print C
a,b=map(int,input().split())
if a%2 == b%2:
  if ((b-a)%2)%2 == 0:
    print(b)
  else:
    if b%2 == 1:
      print(b-1)
    else:
      print(b+1)
else:
  c=b
  bits=[]
  perfect=False
  while b>0:
  bits.append(b%2)
  b= b//2
  if bits.count(1)==1 and bits[-1]==1:
    perfect=True
    b=c-1
    bits=[]
  while b>0:
    bits.append(b%2)
    b= b//2
  for i in range(len(bits)):
    if (bits[i]==1 and a%2==1) or (bits[i]==0 and a%2==0):
      bits[i]=0
    else:
      bits[i]=1
    a= a//2
  ans=0
  for i in range(len(bits)):
    ans+= bits[i]*(2**i)
  if perfect:
    print(ans+c)
  else:
    print(ans)

### FIXED CODE ###

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

def xor(p):
  if p%4 == 0:
    return p
  elif p%4 == 1:
    return 1
  elif p%4 == 2:
    return p+1
  elif p%4 == 3:
    return 0

if a==0:
  print(xor(b))
elif a == b:
  print(a)
else:
  s=max(xor(b),xor(a-1))
  t=min(xor(a-1),xor(b))
  data=[]
  while s>0:
    data.append(s%2)
    s=s//2
  for i in range(len(data)):
    if (data[i] == t%2):
      data[i] = 0
    else:
      data[i] = 1
    t = t//2
  sum=0
  for i in range(len(data)):
    sum+= data[i]*(2**i)
  print(sum)
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

L.sort(key=lambda x:x[2])

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) < 0:
                    flag = 0
                    break
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

### FIXED CODE ###

N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

L.sort(key=lambda x:x[2])

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) > 0:
                    flag = 0
                    break
            else:

                if h == l[2] + abs(x-l[0]) + abs(y-l[1]):
                    flag = 1
                
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)
a = input()
if a.isupper():
  print('A')
 else:
  print('a')

### FIXED CODE ###

#! -*- coding: utf-8 -*-
a = input()
if a.isupper():
    print('A')
else:
    print('a')
import itertools
N, M, Q = map(int, input().split())
a = [int(input()) for _ in range(Q)]
b = [int(input()) for _ in range(Q)]
c = [int(input()) for _ in range(Q)]
d = [int(input()) for _ in range(Q)]
for i in range (Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]
under_flag = True

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            if h[n] != 0:
                under_flag = False

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1:
                H[cx][cy] = ch
            elif under_flag and ch <= H[cx][cy]:
                H[cx][cy] = ch
            elif H[cx][cy] == ch:
                H[cx][cy] = ch
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])


### FIXED CODE ###

#!/usr/bin/env python

N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[0] * FIELD_SIZE for n in range(FIELD_SIZE)]
determined_flag = False

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if n == 0:
                H[cx][cy] = ch

            elif determined_flag:
                if h[n] != 0:
                    if ch == H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                else:
                    if ch >= H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0

            else:
                if h[n] != 0:
                    if ch <= H[cx][cy]:
                        H[cx][cy] = ch
                    else:
                        H[cx][cy] = 0
                else:
                    H[cx][cy] = min(H[cx][cy], ch)
    if h[n] != 0:
        determined_flag = True


for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] >= 1:
            print(cx, cy, H[cx][cy])
N,M = map(int, input().split())

if N = M:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N,M = map(int, input().split())
if N == M:
    print('Yes')
elif N >= M:
    print('No')
s = input()
n = input()
for i in range(n):
  x, y = input()-1, input()-1
  p = min(x, y, s - x - 1, s - y - 1)
  print p % 3 + 1

### FIXED CODE ###


s = input()
n = input()
for i in range(n):
  x, y = map(int, raw_input().split(" "));
  x -= 1;
  y -= 1;
  p = min(x, y, s - x - 1, s - y - 1)
  print p % 3 + 1
import sys
sys.setrecursionlimit(10 ** 7)
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x % MOD
B = np.array(A[1:])
answer += ((first * x // B) % MOD).sum()

print(answer%MOD)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += first * x // A[i]

print(answer%MOD)
from fractions import gcd
import sys
n, x, d = map(int, input().split())
if d < 0:
    d = -d
    x = -x
if d == 0:
    print(n+1 if x != 0 else 0)
    sys.exit()
g = gcd(d, x)
mod = d//g
hani = [[] for _ in range(n+1)]
for k in range(n+1):
    l = x*k+k*(k-1)//2*d
    r = x*k+k*(n*2-k-1)//2*d+d
    hani[k%mod].append((l, 0))
    hani[k%mod].append((r, 1))
ans = 0
for i in range(n+1):
    if not hani[i]:
        break
    hani[i].sort()
    cnt = 0
    l = None
    for a, f in hani[i]:
        if f == 0:#l
            if cnt == 0:
                l = a
            cnt+=1
        else:
            cnt-=1
            if cnt == 0:
                ans+=(a-l)//d
print(ans)

            





        

### FIXED CODE ###

from fractions import gcd
import sys
n, x, d = map(int, input().split())
if d < 0:
    d = -d
    x = -x
if d == 0:
    print(n+1 if x != 0 else 1)
    sys.exit()
g = gcd(d, x)
mod = abs(d//g)
hani = [[] for _ in range(n+1)]
for k in range(n+1):
    l = x*k+k*(k-1)//2*d
    r = x*k+k*(n*2-k-1)//2*d+d
    hani[k%mod].append((l, 0))
    hani[k%mod].append((r, 1))
ans = 0
for i in range(n+1):
    if not hani[i]:
        break
    hani[i].sort()
    cnt = 0
    l = None
    for a, f in hani[i]:
        if f == 0:#l
            if cnt == 0:
                l = a
            cnt+=1
        else:
            cnt-=1
            if cnt == 0:
                ans+=(a-l)//d
print(ans)
n = int(input())
count=0

for num in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
else:
    if count>0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

s=input()

if s.endswith("s"):
    print(s+"es")
else:
    print(s+"s")
n,m=map(int,input().split())
a=list(map(int,input().split()))
sumA=sum(a)
cnt=0
for i in a:
    if i>=sum/(4*m):
        cnt=cnt+1
    else:
        cnt=cnt
if cnt>=m:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
sumA=sum(a)
cnt=0
for i in a:
    if i>=sumA/(4*m):
        cnt=cnt+1
    else:
        cnt=cnt
if cnt>=m:
    print('Yes')
else:
    print('No')
A=input()
print(A*A)

### FIXED CODE ###

A=int(input())
print(A*A)
x <- list(map(int(), input().split()))

for i in x[i]:
    print("Case 1:", x[i])



### FIXED CODE ###

for i in range(10000):
    x = input()
    x = int(x)
    
    if x == 0:
        break
    else:
        print("Case "+ str(i+1) + ": " + str(x))