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

import sys
sys.setrecursionlimit(500000)

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    node[p-1] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    node[p-1] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(n):
    ans.append(l[i])
    ans.reverse()
for i in range(n-1):
    print(ans[i],end=" ")
print(ans[n-1])

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=[-1]*n
l.reverse()
for i in range(n):
    if i%2==0:
        ans[i//2]=l[i]
    else:
        ans[n-1-((i-1)//2)]=l[i]


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

import functools, fractions

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

gcd_max = 0

for i in range(n):
  ad = a[:i] + a[i + 1:]
  gcd = functools.reduce(fractions.gcd, ad)
  if gcd > gcd_max:
    gcd_max = gcd

print(gcd_max)


### FIXED CODE ###

from fractions import gcd

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

gcdl = [0] * n
gcdr = gcdl[:]

gcdl[0]  = a[0]
gcdr[-1] = a[-1] 

for i in range(1, n):
  gcdl[i] = gcd(a[i], gcdl[i - 1])

for i in range(n - 2, -1, -1):
  gcdr[i] = gcd(a[i], gcdr[i + 1])

max_gcd = max(gcdl[-2], gcdr[1])

for i in range(1, n - 1):
  temp_gcd = gcd(gcdl[i - 1], gcdr[i + 1])
  if temp_gcd > max_gcd:
    max_gcd = temp_gcd

print(max_gcd)
### BUGGY CODE ###

# coding: utf-8

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

acc = [0]

for i in range(n):
    acc.append(acc[i]+a[i])    

count = 0
for i in range(n+1):
    for j in range(i):
        if (acc[i]- acc[j]) %m == 0:
            count += 1

print(count)

### FIXED CODE ###

# coding: utf-8
#始点を定めて(n)終点を定めて(n)その間の数を足し合わせる(～n)と計算量オーダーはO(n^3)
#累積和を用いると、始点を定めて(n)終点を定めて(n)差をとればいいので計算量オーダーはO(n^2)
#以下のコードでは、Aのループ処理(n)において随時累積和のmod mを算出し、そのmod mが何回現れたかを示す辞書の検索、挿入を行う(1)ので、計算量オーダーはO(n)
#（辞書の検索計算量オーダーについていまいち理解できていない。本当にO(1)なのだろうか？）

n,m = list(map(int,input().split()))
A = list(map(int,input().split()))

modm = 0
#累積和を別のリストに格納する必要はなく、bという変数を1つ用意して、modmにその時点での累積和のmod mを格納すればよい
dic = {0:1}
#{x:y}:Aの各要素を順に処理していくとき、mod mがxである要素が現時点までにy個見つかっていることを表す

cnt = 0
for a in A:
    modm = (modm+a) %m
    cnt += dic.get(modm,0)
    dic[modm] = dic.get(modm,0) + 1
#c[b]では、bをキーとする要素が見つからなかった場合エラーが発生してしまう。
#c.get(b,default)なら、bをキーとする要素が見つからなかった場合デフォルト値を返してくれる。

print(cnt)
### BUGGY CODE ###

#coding:utf-8



def main():
    
    def dbg(*something):
        if DEBUG:
            print(*something)


    #正の宝石を戻すことはない
    #負の宝石を戻すのは後半
    from sys import stdin
    from math import ceil,floor
    DEBUG = False
    N,K = list(map(int,stdin.readline().split()))
    V = list(map(int,stdin.readline().split()))


    #残りk回のとき深さk以下の場所に正の宝石がない→終了
    #i回の操作で取れる石>それまでにとるi-1個の石の和
    #深さiにある石vの価値：v - (それまでにとるi-1個の石の和　except (k-i)個の負の石)
    '''
    '''




    def tansaku(left,right,rK,N,score):
        dbg(V[left:right+1],rK,N,score)

        N.sort()
        # max_v = score + sum(N[rK:])
        max_v = score
        for i in range(rK,len(N)):
            max_v += N[i]


        # n = []
        for i in range(left,min(rK+left, ceil((right - left +1)/2)+left)):
            
            if V[i] <= 0:
                #n.append(V[i])
                continue

            #next_V = V[i+1:left+lenV]
            next_rK = rK - 1 - (i - left)
            next_tmp_v = tansaku(i+1,right,  next_rK, N+V[left:i], score+V[i])
            max_v = max(next_tmp_v , max_v)


            break

        # n = []
        for i in range(right ,max(right - ceil((right-left+1)/2)  ,right-rK)  ,-1 ):
            
            if V[i] <= 0:
                #n.append(V[i])
                continue

            #next_V = V[:i]
            next_rK = rK - 1 - (right - i)
            #next_tmp_v = tansaku(   left,   i- left -1  ,next_rK,N+n,score+V[i])
            next_tmp_v = tansaku(   left,   i-1  ,next_rK,N+V[i+1:right+1],score+V[i])
            max_v = max(next_tmp_v , max_v)
            break


        return max_v

    print(tansaku(0,len(V)-1,K,[],0))





if __name__ == '__main__':
    main()


### FIXED CODE ###

#coding:utf-8



def main():
    
    def dbg(*something):
        if DEBUG:
            print(*something)


    #正の宝石を戻すことはない
    #負の宝石を戻すのは後半
    from sys import stdin
    from math import ceil,floor
    DEBUG = False
    N,K = list(map(int,stdin.readline().split()))
    V = list(map(int,stdin.readline().split()))
    
    max_value = 0
    dbg([i for i in range(3,-1,-1)])
    for getnum in range(1,min(N+1,K+1)):  #取る宝石の総数
        for a in range(getnum + 1):  #左から石を取る回数
            J = [0] * getnum #石
            b = getnum - a #右から石を取る回数
            for i in range(a):
                J[i] = V[i]
            for i in range(b):
                J[a+i] = V[-i-1]
            J.sort()
            #dbg(J,a,b)
            t = min(K-getnum,getnum) #捨てる石
           
            for i in range(t): 
                if J[i] >= 0:
                    t = i
                    break
            #dbg(J,i,t,a,b,J[t:])
            tmp_max = sum(J[t:])

            max_value = max(max_value,tmp_max)
    print(max_value)



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

a, b, x = map(int,input().split())
count = 0
for i in range(a,b+1):
  if i % x == 0:
    count+=1
print(count)

### FIXED CODE ###

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

A = (a-1)//x
B = b//x

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

N = int(input())
A = list(map(int,input().split()))
d = []
num = 10**9 + 7
for i in range(N-1):
    #print(i)
    for j in range(i+1,N):
        #print(j)
        b = A[i] ^ A[j]
        #b %= num
        d.append(b)
print(sum(d)%num)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0
for k in range(60):
    A_0 = 0
    A_1 = 0
    for i in range(N):
        if A[i]>>k&1:
            A_1 += 1
        else:
            A_0 += 1
    num = A_1 * A_0
    ans += (num * 2 ** k)
ans %=  mod
print(ans)
### BUGGY CODE ###

import math
a,b,n = map(int,input().split())
ans = -10000000000 
for i in range(0,n+1):
    kari = math.floor(a*i/b) - a*math.floor(i/b)
    if ans <= kari:
        ans = kari
    else:
        break
print(ans)


### FIXED CODE ###

import math
a,b,n = map(int,input().split())
if b <= n:
    print(math.floor(a*(b-1)/b)-a*math.floor((b-1)/b))
else:
    print(math.floor(a*n/b)-a*math.floor(n/b))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    dp = [[-1 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        dp[i][i] = a[i]
    
    for i in range(N-1,-1,-1):
        for j in range(i,N):
            if dp[i][j] != -1:
                continue
            dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1])
            
    print(dp[0][-1])
   
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    dp = [[-1 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        dp[i][i] = a[i]
    
    for i in range(N-1,-1,-1):
        for j in range(i,N):
            if dp[i][j] != -1:
                continue
            dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1])
            
    print(dp[0][-1])
   
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

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

mod = 10**9+7

def choose(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod # modの世界では逆元はpow(x,mod-2)をかけることと同じ

n = len(s)

ans = 0

for i in range(k+1):
    now = 26**(k-i) % mod
    now *= 25**i % mod
    now *= choose(i+n-1, n-1) % mod
    ans += now % mod

print(ans%mod)

### FIXED CODE ###

"""
keyword: 二項係数

与えられた文字列sの最後の文字以降は何を置いても(26通り)良い一方で、最後の文字より前は同じ文字は置けない(25通り)
そこで最後の文字より後と前で分けて場合の数を考える


"""

import sys
sys.setrecursionlimit(10**6)

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

mod = 10**9+7

n = len(s)
fact = [1, 1] # あとでnの階乗を求める初期値　[0!, 1!]

# n!を求める
for i in range(2, 2*(10**6)+1):
    fact.append(fact[-1]*i % mod)

# 二項係数nCrを求める nCr = n!/r!(n-r)!
def nCr(n, r, mod=10**9+7):
    return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod # modの世界では逆元はpow(x,mod-2)をかけることと同じ

ans = 0
#for i in range(k+1):
#    ans = (ans+nCr(n+k, i)*pow(25, i, mod)) % mod
#print(ans)

for i in range(k+1):
    now = pow(26, k-i, mod) * pow(25, i, mod) * nCr(i+n-1, n-1)
    ans = (ans+now) % mod
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 19:06:03 2020

@author: Kanaru Sato
"""
import math

X = int(input())

target = X
flag = 0

while flag == 0:
    for i in range(2, int(math.sqrt(X))+1):
        if X%i == 0:
            if X%2 == 0:
                X += 1
                break
            else:
                X += 2
                break
        elif i == int(math.sqrt(X)):
            flag = 1
            break
        else:
            continue

print(X)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 19:06:03 2020

@author: Kanaru Sato
"""
import math

X = int(input())

target = X
flag = 0

if X == 2 or X == 3:
    flag = 1

while flag == 0:
    rootX = int(math.sqrt(X))
    for i in range(2, rootX+1):
        if X%i == 0:
            if X%2 == 0:
                X += 1
                break
            else:
                X += 2
                break
        elif i == rootX:
            flag = 1
            break
        else:
            continue

print(X)
### BUGGY CODE ###

import sys

s=list(input())
q=int(input())

for i in range(1,q+1):
    q_i=sys.stdin.readline().rstrip().split()
    if q_i[0]=="1":
        s=s[::-1]
    else:
        if q_i[1]=="1":
            s=[q_i[2]]+s
        else:
            s=s+[q_i[2]]

s="".join(s)
print(s)

### FIXED CODE ###

from collections import deque

s=list(input())
s=deque(s)
q=int(input())

re=False
for i in range(1,q+1):
    q_i=input().split()
    if q_i[0]=="1":
        re= not re
    else:
        if q_i[1]=="1" and re==False:
            s.appendleft(q_i[2])
        elif q_i[1]=="2" and re==True:
            s.appendleft(q_i[2])
        else:
            s.append(q_i[2])

s=list(s)

if re==True:
    s=s[::-1]

s="".join(s)
print(s)
### BUGGY CODE ###

from bisect import bisect_left

N = int(input())
S = input()

R_index = []
G_index = []
B_index = []

for i, s in enumerate(S):
    if s == 'R':
        R_index.append(i)
    elif s == 'G':
        G_index.append(i)
    elif s == 'B':
        B_index.append(i)

ans = 0
for i in R_index:
    sj = bisect_left(G_index, i)
    for ij in range(sj, len(G_index)):
        j = G_index[ij]
        sk = bisect_left(B_index, j)
        for ik in range(sk,len(B_index)):
            k = B_index[ik]
            if i < j < k and j - i != k - j:
                ans += 1

    sj = bisect_left(B_index, i)
    for ij in range(sj,len(B_index)):
        j = B_index[ij]
        sj = bisect_left(G_index, j)
        for ik in range(sj,len(G_index)):
            k = G_index[ik]
            if i < j < k and j - i != k - j:
                ans += 1

for i in G_index:
    sj = bisect_left(B_index, i)
    for ij in range(sj, len(B_index)):
        j = B_index[ij]
        sk = bisect_left(R_index, j)
        for ik in range(sk,len(R_index)):
            k = R_index[ik]
            if i < j < k and j - i != k - j:
                ans += 1

    sj = bisect_left(R_index, i)
    for ij in range(sj,len(R_index)):
        j = R_index[ij]
        sj = bisect_left(B_index, j)
        for ik in range(sj,len(B_index)):
            k = B_index[ik]
            if i < j < k and j - i != k - j:
                ans += 1

for i in B_index:
    sj = bisect_left(R_index, i)
    for ij in range(sj, len(R_index)):
        j = R_index[ij]
        sk = bisect_left(G_index, j)
        for ik in range(sk,len(G_index)):
            k = G_index[ik]
            if i < j < k and j - i != k - j:
                ans += 1

    sj = bisect_left(G_index, i)
    for ij in range(sj,len(G_index)):
        j = G_index[ij]
        sj = bisect_left(R_index, j)
        for ik in range(sj,len(R_index)):
            k = R_index[ik]
            if i < j < k and j - i != k - j:
                ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = input()

counter = Counter(S)
r_count = counter['R']
g_count = counter['G']
b_count = counter['B']

ans = r_count * g_count * b_count
for i in range(N):
    for j in range(N):
        k = 2 * j - i
        if k > N-1:
            break
        if i < j < k and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1

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

N = int(input())
T = [[]for i in range(N)]
A = []
D = [[0]*N for i in range(N)]
for i in range(N-1):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)
    A.append((a,b))
K = 0
for t in T:
    K = max(K,len(t))
print(K)
Q = [(0,-1,0)]
while Q:
    q = Q.pop(-1)
    v,p,k = q[0],q[1],q[2]
    ck = 1
    for c in T[v]:
        if ck==k:ck+=1
        if c!=p:
            Q.append((c,v,ck))
            D[c][v] = ck
            D[v][c] = ck
            ck+=1
for a in A:
    print(D[a[0]][a[1]])

### FIXED CODE ###

from collections import deque
N = int(input())
ab = [list(map(lambda x:int(x)-1,input().split())) for i in range(N-1)]
T = [[] for i in range(N)]
for a,b in ab:
    T[a].append(b)
q = deque([0])
color = [0]*N
while q:
    x = q.popleft()
    c = 1
    for y in T[x]:
        if c==color[x]:
            c+=1
        color[y] = c
        c+=1
        q.append(y)
print(max(color))
for i in range(N-1):
    print(color[ab[i][1]])
### BUGGY CODE ###

n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')
for i in range(n - k + 1):
  l = x[i:i + k]
  ans = min(ans, abs(l[0]) + abs(l[-1] - l[0]), abs(l[-1]) + abs(l[-1] - l[0]))
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')
for i in range(n - k + 1):
  ans = min(ans, abs(x[i]) + abs(x[i + k - 1] - x[i]))
  ans = min(ans,  abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]))
print(ans)
### BUGGY CODE ###

n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
t = [[0] * n for i in range(n)]
for i in range(n-1):
    cc, cs, cf = csf[i][0], csf[i][1], csf[i][2]
    t[i][i] = cs
    for j in range(1+i):
        cs = csf[i][1]
        while t[j][i] > cs:
            cs += cf
        t[j][i+1] = cs + cc 
for i in range(n):
    print(t[i][n-1])

### FIXED CODE ###

n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
t = [[0] * n for i in range(n)]
for i in range(n-1):
    cc, cs, cf = csf[i][0], csf[i][1], csf[i][2]
    t[i][i] = cs
    for j in range(1+i):
        cs = csf[i][1]
        while t[j][i] > cs:
            cs += cf
        t[j][i+1] = cs + cc 
for i in range(n):
    print(t[i][n-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(4100000)

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


def dfs(day, money,stock):
    if day == N:
        pricelist.append(money+ stock * A[N-1])
        return
    price = A[day-1]
    dfs(day+1, money % price, stock + money//price)
    dfs(day+1, money, stock)
    dfs(day+1, money + stock * price, 0)
    return

dfs(1,1000,0)

print(max(pricelist))




### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
money = 1000
for i in range(N-2):
    today, tomorrow = A[i], A[i+1]
    if today < tomorrow:
        money = (money//today)*tomorrow + money%today
if A[N-2]< A[N-1]:
    money = (money//A[N-2]) * A[N-1] + money%A[N-2]

print(money)
### BUGGY CODE ###

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

dp = [0]*(N+1)
dp[0] = 1
ans = 0

for i in range(1, N+1):
    if i in a:
        dp[i] = 0
        if dp[i-1] == 0:
            ans = 0
            break
    else:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            dp[i] = dp[i-1]

else:
    ans = dp[-1] % 1000000007

print(ans)


### FIXED CODE ###

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

dp = [-1]*(N+1)
for i in a:
    dp[i] = 0

dp[0] = 1
mod = 1000000007

for i in range(1, N+1):
    if dp[i] == 0:
        continue
    else:
        if i > 1:
            dp[i] = (dp[i-1] + dp[i-2]) % mod
        else:
            dp[i] = dp[i-1] % mod

print(dp[-1])
### BUGGY CODE ###

while 1:
    n=int(input())
    if not n:break
    l=[int(input()) for _ in range(n)]
    print(max(sum(l[j:i]) for i in range(len(l)+1) for j in range(i)))



### FIXED CODE ###

while 1:
    n=int(input())
    if not n:break
    dp=[0 for _ in range(n)]
    dp[0]=int(input())
    for i in range(1,n):
        v=int(input())
        dp[i]=max(dp[i-1]+v,v)
    print(max(dp))
### BUGGY CODE ###

import itertools
N = int(input())
L = list(map(int,input().split()))
C = itertools.combinations(L,3)
count = 0
for c in C:
    if c[0] < c[1]+c[2] and c[1] < c[0]+c[2] and c[2] < c[0]+c[1]:
        count += 1
print(count)

### FIXED CODE ###

import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
lenl = len(L)
count = 0
for i in range(0,lenl-2):
    for j in range(i+1,lenl-1):
        count += bisect.bisect_left(L,L[i]+L[j])-j-1
print(count)
### BUGGY CODE ###

from collections import Counter
 
N = int(input())
S = []
ans = [1] * N
for _ in range(N):
    s = Counter(input())
    for i in range(len(S)):
        if s == S[i]:
            ans[i] += 1
            break
    else:
        S.append(s)
        
print(sum(a * (a-1) // 2 for a in ans if a > 1))

### FIXED CODE ###

from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))
### BUGGY CODE ###

S = list(input())
Q = int(input())
lst = []

for i in range(Q):
    tmp = list(input().split())
    lst.append(tmp)

reverse = 0
c = 1
for i in range(Q):

    if int(lst[i][0]) == 1:
        reverse += 1
        c += 1
    
    if int(lst[i][0]) == 2:
        if c%2 == 1:
            if int(lst[i][1]) == 1:
                S.insert(0,lst[i][2])
            else:
                S.append(lst[i][2])
        else:
            if int(lst[i][1]) == 2:
                S.insert(0,lst[i][2])
            else:
                S.append(lst[i][2])

if reverse%2 == 1:
    S.reverse()

ans = "".join(S)
print(ans)

### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())
lst = deque()

for i in range(Q):
    tmp = list(input().split())
    lst.append(tmp)

reverse = 0
c = 1
for i in range(Q):

    if int(lst[i][0]) == 1:
        reverse += 1
        c += 1
    
    if int(lst[i][0]) == 2:
        if c%2 == 1:
            if int(lst[i][1]) == 1:
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])
        else:
            if int(lst[i][1]) == 2:
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])

if reverse%2 == 1:
    S.reverse()

ans = "".join(S)
print(ans)
### BUGGY CODE ###

def lcm(a):
  from fractions import gcd
  x = a[0]
  for i in range(1, len(a)):
    x = (x * a[i] // gcd(x, a[i]))
  return x

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

mod = 1000000000 + 7
min = lcm(a)
sum = 0
for i in range(n):
  sum = sum + (min//a[i])%mod 
  
print(sum%mod)



### FIXED CODE ###

from fractions import gcd
from functools import reduce
     
mod = 10 ** 9 + 7
     
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
     
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
     
    # print('input >>')
N = int(input())
A = list(map(int,(input().split())))
     
lcmn = lcm(A)
    
ans = 0
for i in range(len(A)):
    ans += lcmn // A[i]
     
    # print('-----output-----')
print(int(ans%mod))
### BUGGY CODE ###

N=int(input())
a=list(map(int,input().split()))
tmp=[]
X=sum(a)
tmp=[abs(X-2*sum(a[0:i])) for i in range(1,N)]
print(min(tmp))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
tmp=[]
X=sum(a)
x=0
ans=1000000000000000000
for i in range(N):
    x+=a[i]
    if i+1<N:
        ans=min(ans,abs(X-2*x))

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

def resolve():
    n = int(input())
    s_list = list(input())
    mod = 10 ** 9 + 7

    from math import factorial

    l_counter = 0
    res = 1

    for i in range(2 * n):
        s = s_list[i]
        if i % 2 == 0:
            s = "W" if s == "B" else "B"

        if s == "W":
            l_counter += 1
        else:
            res *= l_counter
            l_counter -= 1
            if l_counter < 0:
                print(0)
                return

    if l_counter != 0:
        print(0)
    else:
        print(res * factorial(n) % mod)
        
resolve()

### FIXED CODE ###

import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))
### BUGGY CODE ###

import sys

while 1:
  n=input()
  if n==0:break
  A=[raw_input() for i in range(n)]
  B=[]
  c=0
  for i in range(n):
    if c==0 and '1' in A[i]: c=1
    B.append(int(A[i].replace('.','1').replace('*','0'),2))
  C=B[:]
  for i in range(1,n):
    for j in range(n-i):
      B[j]&=B[j+1]
      if '1'*(i+1) in format(B[j],'b'): c=i+1
    if c!=i+1: break
  print c

### FIXED CODE ###

import sys

while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [0] * n
  y = [0] * n
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],y[j],x[j-1]) + 1
    M[i]=max(x)
    y = x
  print max(M)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
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
div = []
for i in A:
    div += make_divisors(i)
from collections import Counter
c = Counter(div)
ans = 0
for i in c.keys():
    if c[i] >= N - 1:
        ans = max(ans, i)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))

L = [A[0]]
R = [A[-1]]
A_R = A[::-1]
for i in range(1, N):
    L.append(fractions.gcd(L[-1], A[i]))
    R.append(fractions.gcd(R[-1], A_R[i]))
R = R[::-1]
ans = R[1]
R.append(0)
for i in range(N - 1):
    ans = max(ans, fractions.gcd(L[i],R[i+2]))
print(ans)