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

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

def solve(N: int, A: "List[int]"):
    A.sort()
    ret = 0
    used = [False] * N
    for i, v in enumerate(A):
        if used[i]:
            continue
        if not (i < N - 1 and v == A[i + 1]):
            ret += 1
        for j in range(i + 1, N):
            if A[j] % v == 0:
                used[j] = True
    print(ret)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

def solve(N: int, A: "List[int]"):
    counts = {}
    for a in A:
        if not a in counts:
            counts[a] = 0
        counts[a] += 1

    M = max(A)
    s = set(A)
    ret = 0
    used = [False] * (M + 1)
    for i in range(1, M + 1):
        if used[i]:
            continue
        if not i in s:
            continue
        if counts[i] == 1:
            ret += 1
        j = 1
        while i * j <= M:
            used[i * j] = True
            j += 1
    print(ret)


def _hoge(N, A):
    for i, v in enumerate(A):
        if used[i]:
            continue
        if not (i < N - 1 and v == A[i + 1]):
            ret += 1
        for j in range(i + 1, N):
            if A[j] % v == 0:
                used[j] = True
    print(ret)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

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

import numpy as np
s = input()
t = input()

dp = np.zeros((len(t)+1, len(s)+1))
for i in range(1, len(t)+1):
    ti = t[i-1]
    dp[i] = dp[i-1]
    for j in range(1, len(s)+1):
        if ti == s[j-1]:
            dp[i][j] = dp[i][j-1] + 1
        else:
            if dp[i][j-1] >= dp[i][j]:
                dp[i][j] = dp[i][j-1]
ans = ''
sl = len(s)
tl = len(t)
while sl > 0 and tl > 0:
    if s[sl-1] == t[tl-1]:
        sl -= 1
        tl -= 1
        ans = s[sl] + ans
        continue

    if dp[tl][sl] == dp[tl][sl-1]:
        sl -= 1
    elif dp[tl][sl] == dp[tl-1][sl]:
        tl -= 1
print(ans)


### FIXED CODE ###

s = input()
t = input()
dp = [[0] * (len(s)+1) for _ in range(len(t)+1)]
for i in range(1, len(t)+1):
    ti = t[i-1]
    dp[i] = dp[i-1][:]
    for j in range(1, len(s)+1):
        if ti == s[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])

ans = ''
sl = len(s)
tl = len(t)
while sl > 0 and tl > 0:
    if s[sl-1] == t[tl-1]:
        sl -= 1
        tl -= 1
        ans = s[sl] + ans
        continue
    if dp[tl][sl] == dp[tl][sl-1]:
        sl -= 1
    elif dp[tl][sl] == dp[tl-1][sl]:
        tl -= 1
print(ans)
### BUGGY CODE ###

n, mw = map(int, input().split())
w, v = [], []
for _ in range(n):
    x, y = map(int, input().split())
    w.append(x)
    v.append(y)
dp = [[0 for _ in range(mw+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(mw+1):
        if w[i-1] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[n][mw])


### FIXED CODE ###

n, mw = map(int, input().split())
goods = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(mw+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(mw+1):
        w, v = goods[i]
        if j >= w:
            dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v)
        else: dp[i+1][j] = dp[i][j]
print(dp[n][mw])
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
K=int(input())
s=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            s+=gcd(i,j,k)
print(s)      

### FIXED CODE ###

from math import gcd
K=int(input())
s=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            s+=gcd(gcd(i,j),k)
print(s)
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import connected_components
import scipy.stats as stats

n, m = map(int, input().split( ))
graph = np.array([[0]*n for _ in range(n)])
for _ in range(m):
    a, b = map(int, input().split( ))
    graph[a-1,b-1] = 1
    graph[b-1,a-1] = 1  # 有向グラフなら消す
# print(graph)

num, label = connected_components(graph)

# print(num)
# print(label)

print(stats.mode(label)[1][0])

### FIXED CODE ###

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

import numpy as np
n, m = map(int, input().split( ))

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for i in range(m):
    x,y=map(int,input().split(' '))
    unite(x-1,y-1)

# print(par)
print(-min(par))
### BUGGY CODE ###

n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    hoge = list(map(int,input().split()))
    a.append(hoge[0])
    b.append(hoge[1])
tenbo = list(range(1,n+1))
for i in range(m):
    if h[a[i]-1] > h[b[i]-1] and b[i] in tenbo:
        tenbo.remove(b[i])
    elif h[a[i]-1] < h[b[i]-1] and a[i] in tenbo:
        tenbo.remove(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        if a[i] in tenbo:
            tenbo.remove(a[i])
        if b[i] in tenbo:
            tenbo.remove(b[i])
print(len(tenbo))

### FIXED CODE ###

from collections import Counter
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    hoge = list(map(int,input().split()))
    a.append(hoge[0])
    b.append(hoge[1])

tenbo = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        tenbo.append(b[i])
    elif h[a[i]-1] < h[b[i]-1]:
        tenbo.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        tenbo.append(a[i])
        tenbo.append(b[i])

print(n - len(Counter(tenbo)))
### BUGGY CODE ###

import sys
import heapq

def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))

    h=[]
    for i in range(n):
        if b[i]>a[i]:
            h.append([-1*b[i],i])
    heapq.heapify(h)

    loop=0
    idx=0
    while(1):
    #print(b)
        if not h:
            break
        buf,idx=heapq.heappop(h)
        buf=-1*buf

        x=(buf-a[idx])//(b[(idx-1)%n]+b[(idx+1)%n])
        y=(buf-a[idx])%(b[(idx-1)%n]+b[(idx+1)%n])
        buf=a[idx]+y
        loop+=x
        b[idx]=buf
        if buf<a[idx] or x==0:
            #print(b)
            print(-1)
            sys.exit()
        elif buf>a[idx]:
            heapq.heappush(h,[buf*-1,idx])

    print(loop)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import heapq

def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))

    h=[]
    for i in range(n):
        if b[i]>a[i]:
            heapq.heappush(h,(b[i]*-1,i))

    loop=0
    idx=0
    while(1):
    #print(b)
        if not h:
            break
        buf,idx=heapq.heappop(h)
        buf=-1*buf

        x=(buf-a[idx])//(b[(idx-1)%n]+b[(idx+1)%n])
        buf-=x*(b[(idx-1)%n]+b[(idx+1)%n])
        loop+=x
        b[idx]=buf
        if x==0:
            #print(b)
            print(-1)
            sys.exit()
        elif buf>a[idx]:
            heapq.heappush(h,(buf*-1,idx))

    print(loop)

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

import math
import sys 
input = sys.stdin.readline
N = int(input())
x = list(map(int,input().split()))

d = [0]*(N-1)
for i in range(N-1):
    d[i] = x[i+1]-x[i]
    d[i] %= 10**9+7


kaijou = 1
for i in range(1,N):
    kaijou *= i%(10**9+7)

#kaijou = math.factorial(N-1)%(10**9+7)
ans=0
x=0
k=10**9+5

def pow_r(x, n):
    """
    O(log n)
    """
    x %= (k+2)
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)%(k+2)
    else:  # standard case ② n is odd
        return (x * pow_r(x ** 2, (n - 1) // 2))%(k+2)

for i in range(N-1):
    #(i+1)**(10**9+5)を計算してyへ
    y = pow_r(i+1,k) 
    #x+= kaijou//(i+1))%(10**9+7)
    x += (kaijou*y)%(10**9+7)
    ans+= d[i]*x

print(ans%(10**9+7))


### FIXED CODE ###

import math
import sys 
input = sys.stdin.readline

N = int(input())
x = list(map(int,input().split()))
mod = 10**9+7

d = [0]*(N-1)

for i in range(N-1):
    d[i] = x[i+1]-x[i]
    d[i] %= mod


kaijou = 1
for i in range(1,N):
    kaijou *= i
    kaijou %= mod


ans=0
x=0

def pow_r(x, n):
    """
    O(log n)
    """
    x %= mod
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)%mod
    else:  # standard case ② n is odd
        return (x * (pow_r(x ** 2, (n - 1) // 2)))%mod

for i in range(N-1):
    #(i+1)%(mod-2)を計算してyへ
    y = pow_r(i+1,mod-2)
    #x+= kaijou//(i+1))%(10**9+7)
    x += kaijou*y
    ans += d[i]*x
    ans %= mod

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

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

subst = set()
for fil_i in range(1, len(s)+1):
    for ix in range(0, len(s)):
        if ix + fil_i <= len(s):
            # print(ix,fil_i)
            # print(s[ix:ix+fil_i])
            subst.add(s[ix: ix + fil_i])
        else:
            break

ans = sorted(list(subst))
# print(ans)
print(ans[k-1])


### FIXED CODE ###

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

# tle
subst = set()
for fil_i in range(1, k+1):
    for ix in range(0, len(s)):
        if ix + fil_i <= len(s):

            subst.add(s[ix: ix + fil_i])
        else:
            break

ans = sorted(list(subst))
print(ans[k-1])
### BUGGY CODE ###

#051_B
k,s=map(int,input().split())
print(sum([x+y+z==s for x in range(k+1) for y in range(k+1) for z in range(k+1)]))

### FIXED CODE ###

#051_B
k,s=map(int,input().split())
print(sum([0<=s-x-y<=k for x in range(k+1) for y in range(k+1)]))
### BUGGY CODE ###

h, w = map(int, input().split())

s = [input() for _ in range(h)]

result = []
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        else:
            c = 1
            x = 1
            while i+x < h and s[i+x][j] == ".":
                x += 1
                c += 1
            x = 1
            while i-x >= 0 and s[i-x][j] == ".":
                x += 1
                c += 1
            y = 1
            while j+y < w and s[i][j+y] == ".":
                y += 1
                c += 1
            y = 1
            while j-y >= 0 and s[i][j-y] == ".":
                y += 1
                c += 1
        result.append(c) 
print(max(result)) 

### FIXED CODE ###

h, w = map(int, input().split())

s = [input() for _ in range(h)]

x_inf = [[0 for i in range(w)] for j in range(h)]
y_inf = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    p = -1
    for j in range(w):
        if s[i][j]=="#":
            p = j
        else:
            x_inf[i][j] = p

for i in range(h):
    p = w
    for j in range(-1,-w-1,-1):
        if s[i][j]=="#":
            p = w+j
        else:
            x_inf[i][j] -= p-1

for i in range(w):
    p = -1
    for j in range(h):
        if s[j][i]=="#":
            p = j
        else:
            y_inf[j][i] = p

for i in range(w):
    p = h
    for j in range(h-1,-1,-1):
        if s[j][i]=="#":
            p = j
        else:
            y_inf[j][i] -= p-1
result = []
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            result.append(x_inf[i][j]+y_inf[i][j]+1)
print(-min(result))
### BUGGY CODE ###

import numpy as np
N = int(input())
Hs = list(map(int, input().split()))
As = np.array([Hs for _ in range(N)])
h = np.array([[Hs[i]]*N for i in range(N)])
co = As + h - np.array([[abs(n-i) for i in range(N)] for n in range(N)])
ans = N**2-np.count_nonzero(co)
print(ans//2)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
L = [A[i]+i for i in range(N)]
R = [i-A[i] for i in range(N)]
c = Counter(R)

ans = 0
for l in L:
    ans += c[l]

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

#120 C
S =input()
cnt=0
for i in range(len(S)):
    if S.count('01')>0:
        S=S.replace('01','',1)
        cnt+=2
    if  S.count('10')>0:
        S=S.replace('10','',1)
        cnt+=2
print(cnt)

### FIXED CODE ###

#120 C
S =input()
print(min(S.count('0'),S.count('1'))*2)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

pre_max = 0
af_max = max(A[1:])
print(af_max)
for ii in range(1, N - 1):
    af_max = max(A[ii + 1:])
    pre_max = max(A[ii - 1], pre_max)
    print(max(pre_max, af_max))

print (max(pre_max, A[N - 2]))


### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

pre_max = 0
pre_max_2 = 0
forward = [0]
backward = [0]
for ii in range(1, N):
    pre_max = max(pre_max, A[ii-1])
    forward.append(pre_max)
    pre_max_2 = max(pre_max_2, A[-ii])
    backward.append(pre_max_2)

backward.reverse()

for ii in range(N):
    print(max(forward[ii], backward[ii]))
### BUGGY CODE ###

n = int(input())
arr = list(map(lambda n: format(int(n), '060b')[::-1], input().split()))

mod = 10 ** 9 + 7

res = 0
power_of_two = 1
for d in range(60):
    one = sum(x[d] == "1" for x in arr)
    res += one * (n - one) * power_of_two
    res %= mod
    power_of_two *= 2
    power_of_two %= mod

print(res)


### FIXED CODE ###

n = int(input())
arr = list(map(lambda n: format(int(n), '060b')[::-1], input().split()))

mod = 10 ** 9 + 7

res = 0
power_of_two = 1
for d in range(60):
    one = sum(x[d] == "1" for x in arr)
    res += one * (n - one) * power_of_two
    res %= mod
    power_of_two *= 2
    power_of_two %= mod

print(res)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
r, g0, b0 = 0, 0, 0

while r * R <= N:
  g = g0
  Nr = N
  Nr -= r * R
#  print("Nr:", Nr, "r:", r)
  while g * G <= Nr:
    Ng = Nr
    Ng -= g * G
#    print("Ng:", Ng, "g:", g)
    if Ng % B == 0:
      b = (Ng/B)
      ans += 1
#      print("ANS:", ans, "r:", r, "g:", g, "b:", b)
    g += 1
  r += 1
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
r, g = 0, 0
rmax = N // R
gmax = N // G

if R * G * B == 1:
  for i in range(N + 1):
    ans += N + 1 - i
  print(ans)
  exit()

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * R - j * G) < 0:
      break
    if (N - i * R - j * G) % B == 0:
      ans += 1
#      print(ans, i, j)
print(ans)
### BUGGY CODE ###

N = int(input())
A = [abs(int(input())) for _ in range(N)]
#A.sort()
s = sum(A)

def mulmod(p,q,mod):
  return ((p%mod)*(q%mod))%mod
def powermod(p,n,mod):
  if n==0: return 1
  if n==1: return p%mod
  else:    return powermod(p,n//2,mod)**2 * (p**(n%2)) %mod
def dividemod(p,q,mod):
  # modは素数
  return mulmod(p, powermod(q,mod-2,mod), mod)

mod = 998244353

dp = [[0]*(s+1) for _ in range(N)]
# dp[n][s] An-1(0-index)まで加えて、Rの和がsになるのが何通りか（残りのG,Bまで含めて）
dp[0][0] = 2
dp[0][A[0]] = 1
temp_sum = A[0]

for i in range(1,N):
  for j in range(temp_sum+1):
    dp[i][j] = (dp[i][j]+ dp[i-1][j]*2) %mod
    dp[i][j+A[i]] = (dp[i][j+A[i]] + dp[i-1][j]) %mod
  temp_sum += A[i]


def part_sum(a,A):
  p=mod
  #初期化
  N=len(a)
  dp=[[0 for i in range(A+1)] for j in range(N+1)]
  dp[0][0]=1

  #DP
  for i in range(N):
    for j in range(A+1):
      if a[i]<=j: #i+1番目の数字a[i]を足せるかも
        dp[i+1][j]=dp[i][j-a[i]]+ dp[i][j]% p
      else: #入る可能性はない
        dp[i+1][j]=dp[i][j]%p
  return dp[N][A]

ps = part_sum(A, s//2)

if s%2 != 0:
    answer = (powermod(3, N, mod) - 3*sum(dp[N-1][(s+1)//2:]))%mod
else:
    answer = (powermod(3, N, mod) - 3*(sum(dp[N-1][(s+1)//2:]) - ps))%mod



print(answer)


### FIXED CODE ###

N = int(input())
A = [abs(int(input())) for _ in range(N)]
#A.sort()
s = sum(A)

def mulmod(p,q,mod):
  return ((p%mod)*(q%mod))%mod
def powermod(p,n,mod):
  if n==0: return 1
  if n==1: return p%mod
  else:    return powermod(p,n//2,mod)**2 * (p**(n%2)) %mod
def dividemod(p,q,mod):
  # modは素数
  return mulmod(p, powermod(q,mod-2,mod), mod)

mod = 998244353

dp = [[0]*(s+1) for _ in range(N)]
# dp[n][s] An-1(0-index)まで加えて、Rの和がsになるのが何通りか（残りのG,Bまで含めて）
dp[0][0] = 2
dp[0][A[0]] = 1
temp_sum = A[0]

for i in range(1,N):
  for j in range(A[i]):
    dp[i][j] = (dp[i-1][j]*2) %mod
  for j in range(A[i], temp_sum+1):
    dp[i][j] = (dp[i-1][j]*2 + dp[i-1][j-A[i]]) %mod
  for j in range(temp_sum+1, temp_sum+1 + A[i]):
    dp[i][j] = (dp[i-1][j-A[i]]) %mod
  temp_sum += A[i]


def part_sum(a,A):
  p=mod
  #初期化
  N=len(a)
  dp=[[0 for i in range(A+1)] for j in range(N+1)]
  dp[0][0]=1

  #DP
  for i in range(N):
    for j in range(A+1):
      if a[i]<=j: #i+1番目の数字a[i]を足せるかも
        dp[i+1][j]=dp[i][j-a[i]]+ dp[i][j]% p
      else: #入る可能性はない
        dp[i+1][j]=dp[i][j]%p
  return dp[N][A]

ps = part_sum(A, s//2)

if s%2 != 0:
    answer = (powermod(3, N, mod) - 3*sum(dp[N-1][(s+1)//2:]))%mod
else:
    answer = (powermod(3, N, mod) - 3*(sum(dp[N-1][(s+1)//2:]) - ps))%mod



print(answer)
### BUGGY CODE ###

import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

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

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)

### FIXED CODE ###

import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum([0] + lst)

n = int(input())
lst = list(map(int,input().split()))
d = dict(Counter(f(lst)))

res = 0
for k,v in d.items():
    if v >= 2:
        res += (v*(v-1))//2
print(res)
### BUGGY CODE ###

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

ans = 300010
for i in range(N):
    tmp = 0
    for left in range(i):
        if S[left] == 'W':
            tmp += 1
    for right in range(i + 1, N):
        if S[right] == 'E':
            tmp += 1
    ans = min(ans, tmp)

print(ans)

### FIXED CODE ###

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


left = [0] * N
right = [0] * N

for i in range(0, N):
    if i == 0:
       if S[i] == 'W':
           left[i] = 1
    else:
        if S[i] == 'W':
            left[i] = left[i-1] + 1
        else:
            left[i] = left[i-1]

for i in reversed(range(0, N)):
    if i == N - 1:
        if S[i] == 'E':
            right[i] = 1
    else:
        if S[i] == 'E':
            right[i] = right[i+1] + 1
        else:
            right[i] = right[i+1]

ans = 300010
for i in range(0,N):
    if i == 0:
        ans = min(ans, right[i+1])
    elif i == N -1:
        ans = min(ans, left[i-1])
    else:
        ans = min(ans, left[i-1] + right[i+1])


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

def gcd(x, y):
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

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

g = 0
for x in a:
    g = gcd(g, x)

l = 1
for i in range(n):
    a[i] //= g
    l = lcm(l, a[i])

ans = 0
for i in range(n):
    ans += l//a[i]
    ans %= 10**9+7

print(ans)

### FIXED CODE ###

def gcd(x, y):
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

def modpow(x, n, mod):
    res = 1
    while n > 0:
        if n%2 == 1:
            res = res*x%mod
        x = x*x%mod
        n >>= 1
    return res

mod = 10**9+7

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

g = 0
for x in a:
    g = gcd(g, x)

l = 1
for i in range(n):
    a[i] //= g
    l = lcm(l, a[i])
l %= mod

ans = 0
for i in range(n):
    ans += l*modpow(a[i], mod-2, mod)
    ans %= mod

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

#!/home/matsumotokazuho/.pyenv/shims/pypy
# import math
# from copy import deepcopy
# from operator import itemgetter
# from collections import defaultdict
# from collections import Counter
from collections import deque
# import pprint
import itertools
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H, W = map(int, input().split())
Board = [list(input().rstrip()) for _ in range(H)]

q = deque()
for i, j in itertools.product(range(H), range(W)):
    if Board[i][j] == '#':
        Board[i][j] = 0
        q.append((i, j))

while q:
    for d in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        y, x = [i+j for i, j in zip(q[0], d)]
        if y < 0 or H - 1 < y or x < 0 or W - 1 < x:
            pass
        elif Board[y][x] == '.':
            Board[y][x] = Board[q[0][0]][q[0][1]] + 1
            q.append((y, x))
    q.popleft()

# ans = max(list(itertools.chain.from_iterable(Board)))
ans = max(itertools.chain.from_iterable(Board))
# pprint.pprint(Board)
print(ans)


### FIXED CODE ###

#!/home/matsumotokazuho/.pyenv/shims/pypy
# import math
# from copy import deepcopy
# from operator import itemgetter
# from collections import defaultdict
# from collections import Counter
# from collections import deque
# import pprint
# import itertools
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H, W = map(int, input().split())
Board = [list(input().rstrip()) for _ in range(H)]

# q = deque()
q = []
# for i, j in itertools.product(range(H), range(W)):
for i in range(H):
    for j in range(W):
        if Board[i][j] == '#':
            # Board[i][j] = 0
            q.append((i, j))

ans = 0
while q:
    qq = []
    ans += 1
    for yx in q:
        for d in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            y = yx[0] + d[0]
            x = yx[1] + d[1]
            # y, x = [i+j for i, j in zip(yx, d)]
            if y < 0 or H - 1 < y or x < 0 or W - 1 < x:
                pass
            elif Board[y][x] == '.':
                # Board[y][x] = Board[q[0][0]][q[0][1]] + 1
                Board[y][x] = '#'
                qq.append((y, x))
    q = qq

# ans = max(list(itertools.chain.from_iterable(Board)))
# ans = max(itertools.chain.from_iterable(Board))
# pprint.pprint(Board)
print(ans-1)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

MAXN = 10**6+10
facts = [-1,-1] + [0]*MAXN
p = 2
while p*p <= MAXN:
    if facts[p] == 0:
        for q in range(p*p,MAXN+1,p):
            if facts[q]==0:
                facts[q] = p
    p += 1

from collections import Counter
ctr = Counter()
cs = [Counter() for i in range(N)]
for i,a in enumerate(A):
    while facts[a] > 0:
        cs[i][facts[a]] += 1
        a //= facts[a]
    cs[i][a] += 1
    ctr |= cs[i]

ans = 0
for c in cs:
    t = 1
    for k,v in (ctr - c).items():
        t *= k**v
    ans += t
ans %= MOD
print(ans)

### FIXED CODE ###

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

lcm = 1
for a in A:
    lcm = lcm // gcd(lcm,a) * a

ans = 0
for a in A:
    ans += lcm // a
ans %= MOD
print(ans)
### BUGGY CODE ###

N, *d = map(int, open(0).read().split())
m=d.index(max(d))
for i in range(N-1):
    if(i==m):
        temp=d[i]
        d[i]=0
        y=max(d)
        print(y)
        d[i]=temp
    
    print(max(d))

### FIXED CODE ###

N, *d = map(int, open(0).read().split())
m=d.index(max(d))
c=[max(d)] *N
d[m]=0
y=max(d)
c[m]=y
for i in range(len(c)):
    print(c[i])