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


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

total = 0

total_list = []

for i in range(N):
    to_E = S.count('W', 0, i)
    to_W = S.count('E', i + 1, N + 1)
    total_list.append(to_E + to_W)

print(min(total_list))


### FIXED CODE ###


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

count_W = []
count = 0
for i in range(N):
    if i == 0:
        count_W.append(0)
    else:
        if S[i-1:i] == 'W':
            count += 1
        count_W.append(count)

count_E = []
for i in range(N):
    count_E.append(0)
count = 0
for i in range(N - 1, -1, -1):
    if S[i+1:i+2] == 'E':
        count += 1
    count_E[i] = count

total_list = []
for i in range(N):
    to_E = count_W[i]
    to_W = count_E[i]
    total_list.append(to_E + to_W)

print(min(total_list))
### BUGGY CODE ###

N = int(input())
X = input()
ncnt = X.count('1')

for i in range(N):
    tmp = X
    tmpcnt = ncnt
    cnt = 0
    if tmp[i] == '0':
        tmp = tmp[:i] + '1' + tmp[i + 1:]
        tmpcnt += 1
    else:
        tmp = tmp[:i] + '0' + tmp[i + 1:]
        tmpcnt -= 1
    f = int(tmp, 2)
    while True:
        if f == 0:
            break

        m, d = divmod(f, tmpcnt)
        cnt += 1
        f = d
        tmpcnt = bin(f).count('1')
    print(cnt)


### FIXED CODE ###

n = int(input())
s = input()
x = [0] * n

def pcnt(x):
    return bin(x).count('1')

def f(x):
    if x == 0: return 0
    return f(x % pcnt(x)) + 1

for i in range(n):
    x[i] = int(s[i])

pc = sum(x)
ans = [0] * n
for b in range(2):
    npc = pc
    if b == 0:
        npc += 1
    else:
        npc -= 1

    if npc <= 0: continue

    r0 = 0
    for i in range(n):
        r0 = (r0 * 2) % npc
        r0 += x[i]

    k = 1
    for i in range(n - 1, -1, -1):
        if x[i] == b:
            r = r0
            if b == 0:
                r = (r + k) % npc
            else:
                r = (r - k + npc) % npc
            ans[i] = f(r) + 1
        k = (k * 2) % npc

for i in ans:
    print(i)
### BUGGY CODE ###

N = int(input())
abc = [chr(i) for i in range(97, 97+26)]
ss = []

for i in range(N):
    s = input()
    cnt = []
    for j in abc:
        num = s.count(j)
        cnt.append(num)
    ss.append(cnt)

ans = 0

for i in ss:
    k = ss.count(i)
    ans += k-1

print(int(ans/2))


### FIXED CODE ###

N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

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

def main():

    R, C, K = map(int, input().split())
    a = dict()
    for _ in range(K):
        r, c, v = map(int, input().split())
        a[(r-1, c-1)] = v

    dp = [[[0, 0, 0, 0] for _ in range(C+1)] for _ in range(R+1)]

    for i in range(R):
        for j in range(C):
            for k in range(4):
                dp[i+1][j+1][k] = dp[i+1][j][k]
                dp[i+1][j+1][0] = max(dp[i+1][j+1][0], max(dp[i][j+1]))
            if (i, j) in a:
                dp[i+1][j+1][1] = max([dp[i+1][j+1][1],  dp[i+1][j][0] + a[(i, j)],  max(dp[i][j+1]) + a[(i, j)]])
                dp[i+1][j+1][2] = max([dp[i+1][j+1][2], dp[i+1][j][1] + a[(i, j)] ])
                dp[i+1][j+1][3] = max([dp[i+1][j+1][3], dp[i+1][j][2] + a[(i, j)] ])

    return max(dp[R][C])


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

def main():

    R, C, K = map(int, input().split())
    a = dict()
    for _ in range(K):
        r, c, v = map(int, input().split())
        a[(r-1, c-1)] = v

    dp = [[[0]*4 for _ in range(C+1)] for _ in range(2)]

    for i in range(R):
        for j in range(C):
            v = max(dp[0][j+1])
            u = 0
            if (i, j) in a: u = a[(i, j)]
            dp[1][j+1][0] = max(dp[1][j+1][0], v)
            dp[1][j+1][1] = max(dp[1][j+1][1], dp[1][j][1], dp[1][j][0] + u,  v + u)
            dp[1][j+1][2] = max(dp[1][j+1][2], dp[1][j][2], dp[1][j][1] + u )
            dp[1][j+1][3] = max(dp[1][j+1][3], dp[1][j][3], dp[1][j][2] + u )
        dp[1], dp[0] = dp[0], dp[1]

    return max(dp[0][C])

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

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(N)] for _ in range(N)]
    for length in range(1, N + 1):
        for left in range(N - length + 1):
            right = left + length - 1
            val = 0
            if left == right:
                val = A[left]
            else:
                val = max([
                    A[left] - dp[left + 1][right],
                    A[right] - dp[left][right - 1]
                ])
            dp[left][right] = val
    print(dp[0][N - 1])


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(N)] for _ in range(N)]
    for length in range(1, N + 1):
        for left in range(N - length + 1):
            right = left + length - 1
            val = 0
            if left == right:
                val = A[left]
            else:
                val = max([
                    A[left] - dp[left + 1][right],
                    A[right] - dp[left][right - 1]
                ])
            dp[left][right] = val
    print(dp[0][N - 1])


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

N,W=map(int,input().split())
WV=[]
for _ in range(N):
    WV.append(tuple(map(int,input().split())))
#i番目までの品物をコストw以下になるように選ぶ
dp=[[0]*(N+1) for _ in range(W+1)]
for i in range(1,N+1):
    for w in range(1,W+1):
        if w<WV[i-1][0]:
            dp[w][i]=dp[w][i-1]
        else:
            dp[w][i]=max(dp[w][i-1],dp[w-WV[i-1][0]][i-1]+WV[i-1][1])
print(dp[W][N])

### FIXED CODE ###

N,W=map(int,input().split())
WV=[]
for _ in range(N):
    WV.append(tuple(map(int,input().split())))
#i番目までの品物をコストw以下になるように選ぶ
dp=[[0]*(N+1) for _ in range(W+1)]
for i in range(1,N+1):
    for w in range(1,W+1):
        if w<WV[i-1][0]:
            dp[w][i]=dp[w][i-1]
        else:
            dp[w][i]=max(dp[w][i-1],dp[w-WV[i-1][0]][i-1]+WV[i-1][1])
print(dp[W][N])
### BUGGY CODE ###

n = int(input())
s = input()
"""
def f(char, start, end):
    global rgb
    return rgb[char][end] - rgb[char][start]

rgb = {'R':[0]*(n+1), 'G':[0]*(n+1), 'B':[0]*(n+1)}
for i in range(1, n+1):
    j = s[i-1]
    rgb['R'][i] = rgb['R'][i-1] + (j=='R')
    rgb['G'][i] = rgb['G'][i-1] + (j=='G')
    rgb['B'][i] = rgb['B'][i-1] + (j=='B')

print(rgb['R'])
print(rgb['G'])
print(rgb['B'])

print(f('R', 0,0) )
print(f('R', 0,1) )
print(f('R', 0,2) )
print(f('R', 0,3) )
print(rgb['R'][-1] * rgb['G'][-1] * rgb['B'][-1])
ans = rgb['R'][-1] * rgb['G'][-1] * rgb['B'][-1]
"""
rgb = {'R':0, 'G':0,'B':0}
for i in range(1, n+1):
    j = s[i-1]
    rgb[j] += 1
ans = rgb['R'] * rgb['G'] * rgb['B']
for j in range(1, n):
    for i in range(j):
        if j-i>(n-1)-j: continue
        if s[j]!=s[i] and s[j+(j-i)]!=s[j] and s[j+(j-i)]!=s[i] :
            ans -= 1

print(ans)


### FIXED CODE ###

n = int(input())
s = input()
"""
def f(char, start, end):
    global rgb
    return rgb[char][end] - rgb[char][start]

rgb = {'R':[0]*(n+1), 'G':[0]*(n+1), 'B':[0]*(n+1)}
for i in range(1, n+1):
    j = s[i-1]
    rgb['R'][i] = rgb['R'][i-1] + (j=='R')
    rgb['G'][i] = rgb['G'][i-1] + (j=='G')
    rgb['B'][i] = rgb['B'][i-1] + (j=='B')

print(rgb['R'])
print(rgb['G'])
print(rgb['B'])

print(f('R', 0,0) )
print(f('R', 0,1) )
print(f('R', 0,2) )
print(f('R', 0,3) )
print(rgb['R'][-1] * rgb['G'][-1] * rgb['B'][-1])
ans = rgb['R'][-1] * rgb['G'][-1] * rgb['B'][-1]
"""
rgb = {'R':0, 'G':0,'B':0}
for i in range(1, n+1):
    j = s[i-1]
    rgb[j] += 1
ans = rgb['R'] * rgb['G'] * rgb['B']
for j in range(1, n):
    for i in range(j):
        if j-i>(n-1)-j: continue
        if s[j]!=s[i] and s[j+(j-i)]!=s[j] and s[j+(j-i)]!=s[i] :
            ans -= 1

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

def prime_list(n):
	primes = set(range(2, n + 1))
	for i in range(2, int(n ** 0.5 + 1)):
		primes.difference_update(range(i * 2, n + 1, i))
	return list(primes)

q = int(input())
primes = prime_list(10**5)

for i in range(q):
	l, r = map(int, input().split())
	cnt = 0
	for j in range(l, r+1):
		if j in primes and (j+1)//2 in primes:
			cnt += 1
	print(cnt)



### FIXED CODE ###

# O(nloglogn) https://mathtrain.jp/eratosthenes
def sieve(n):
	s = [True] * n
	s[0] = s[1] = False
	for x in range(2, int(n ** 0.5) + 1):
		if s[x]:
			for i in range(2 * x, n, x):
				s[i] = False
	return s

is_prime = sieve(10 ** 5 + 1)
is_like2017 = [False] * (10 ** 5 + 1)
for i in range(10**5 + 1):
	if is_prime[i] and is_prime[(i + 1) // 2]:
		is_like2017[i] = True

# 区間内のlike2017を求める
# 累積和を用いて高速化
c = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5 + 1):
	if is_like2017[i]:
		c[i] = c[i - 1] + 1
	else:
		c[i] = c[i-1]

# 出力
q = int(input())

for i in range(q):
	l, r = map(int, input().split())
	print(c[r] - c[l-1])
### BUGGY CODE ###

n=int(input())
import heapq
hqx=[]
hqy=[]
for i in range(n):
    x,y=map(int,input().split())
    heapq.heappush(hqx,(x,i))
    heapq.heappush(hqy,(y,i))
prex,prexi=heapq.heappop(hqx)
prey,preyi=heapq.heappop(hqy)
edges=[]#(cost,v1,v2)
for i in range(n-1):
    x,xi=heapq.heappop(hqx)
    y,yi=heapq.heappop(hqy)
    heapq.heappush(edges,(x-prex,prexi,xi))
    heapq.heappush(edges,(y-prey,preyi,yi))
    prex,prexi=x,xi
    prey,preyi=y,yi

frag=list(range(n+1))
fragnum=[0]*(n+1)

#以下でフラグ建設 フラグが同じなら同じチームである
def takefrag(p):
    stock=[]
    while frag[frag[p]]!=frag[p]:
        stock.append(p)
        p=frag[p]
    p=frag[p]
    for i in stock:
        frag[i]=p
    return p

count=0
ans=0
while True:
    cost,a,b=heapq.heappop(edges)
    f1,f2 = map(takefrag,(a,b))
    if f1!=f2:
        count+=1
        f1,f2 = min(f1,f2),max(f1,f2)
        frag[f1]=f2
        ans+=cost
    if count==n-1:
        break

print(ans)

### FIXED CODE ###

n=int(input())
hqx=[]
hqy=[]
for i in range(n):
    x,y=map(int,input().split())
    hqx.append((x,i))
    hqy.append((y,i))
hqx.sort()
hqy.sort()
prex,prexi=hqx[0]
prey,preyi=hqy[0]
edges=[]#(cost,v1,v2)
for i in range(1,n):
    x,xi=hqx[i]
    y,yi=hqy[i]
    edges.append((x-prex,prexi,xi))
    edges.append((y-prey,preyi,yi))
    prex,prexi=x,xi
    prey,preyi=y,yi
edges.sort()

frag=list(range(n+1))
fragnum=[0]*(n+1)

def takefrag(p):
    stock=[]
    while frag[frag[p]]!=frag[p]:
        stock.append(p)
        p=frag[p]
    p=frag[p]
    for i in stock:
        frag[i]=p
    return p

count=0
ans=0
for i in range(2*n):
    cost,a,b=edges[i]
    f1,f2 = map(takefrag,(a,b))
    if f1!=f2:
        count+=1
        f1,f2 = min(f1,f2),max(f1,f2)
        frag[f1]=f2
        ans+=cost
    if count==n-1:
        break

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

from collections import defaultdict
s = input()
sur = []
n = len(s)
p = 2019
ans = 0
for i in range(n-1, -1, -1):
    sur += [int(s[i:]) % p]

d = defaultdict(int)
for x in sur:
    d[x] += 1

for k,v in d.items():
    if k == 0:
        ans += v * (v+1) // 2
    else:
        ans += v * (v-1) // 2
print(ans)

### FIXED CODE ###

from collections import defaultdict
s = input()
n = len(s)
p = 2019
sur1 = [int(s[0]) % p]
sur2 = [int(s[-1]) % p]
sur10 = [1 % p]
for i in range(n - 1):
    sur1 += [(sur1[i] * 10 + int(s[i + 1])) % p]
    sur10 += [(sur10[i] * 10) % p]
    sur2 += [(sur2[i] + sur10[i + 1] * int(s[-i - 2])) % p]

ans = 0
d = defaultdict(int)
for x in sur2:
    d[x] += 1

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

def li():
    return [int(x) for x in input().split()]
INF = 10**18
import itertools as it


N, A, B, C = li()
sl = [int(input()) for x in range(N)]
todo_stack = [sl]
candidate_lists = []
seen = []
minmp = INF
target = [A, B, C]
target.sort()
minl = []
while len(todo_stack) > 0:
    l = todo_stack.pop()
    if l in seen:
        continue
    seen.append(l)
    n = len(l)
    cs = it.combinations(l, 3)
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i==j or j==k or k==i:
                    continue
                bamboos = [l[i], l[j], l[k]]
                bamboos.sort()
                diff = abs(bamboos[0] - target[0]) + abs(bamboos[1] - target[1]) + abs(bamboos[2] - target[2])
                mp = (N - n) * 10 + diff
                if mp < minmp:
                    minmp = mp
                    minl = l
    if len(l) <= 3:
        continue
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            syn = l[i] + l[j]
            others = [l[k] for k in range(n) if (k != i and k != j)]
            newl = others + [syn]
            if len(newl) >= 3:
                todo_stack.append(newl)

print(minmp)


### FIXED CODE ###

def li():
    return [int(x) for x in input().split()]
INF = 10**18
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, A, B, C = li()
l = [int(input()) for x in range(N)]

def dfs(index, a, b, c, none):
    # 終端
    if index == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return INF
    # ツリー構造
    v1 = dfs(index+1, a + l[index], b, c, none) + (10 if a > 0 else 0)
    v2 = dfs(index+1, a, b + l[index], c, none) + (10 if b > 0 else 0)
    v3 = dfs(index+1, a, b, c + l[index], none) + (10 if c > 0 else 0)
    v4 = dfs(index+1, a, b, c, none+1)
    return min(v1, v2, v3, v4)

ans = dfs(0, 0, 0, 0, 0)
print(ans)
### BUGGY CODE ###

from collections import deque
s = deque(input())
n = int(input())
for _ in range(n):
    a = input()
    if len(a) != 1:
        b = list(a.split())
        if b[1] == '2':
            s.append(b[2])
        else:
            s.appendleft(b[2])
    else:
        s.reverse()
else:
    print(''.join(s))
            


        

### FIXED CODE ###

from collections import deque
s = deque(input())
n = int(input())
re = 0
st = ''
en = ''
for i in range(n):
    a = list(input().split())
    if a[0]=='1':
        re = 1 if re==0 else 0
    else:
        if a[1]=='1':
            if re==0:
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if re==0:
                s.append(a[2])
            else:
                s.appendleft(a[2])
if re==1:
    s.reverse()
res = list(s)
print(''.join(res))
### BUGGY CODE ###

#!/usr/bin/ruby
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a, n, g):
	global cnt
	for i in range(g,n):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a, n):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= n:
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a, n, g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a,len(a))
print(cnt)
for e in a: print(e)

### FIXED CODE ###

#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
	global cnt
	for i in range(g,len(a)):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= len(a):
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)
### BUGGY CODE ###

from math import factorial

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


def comb(n,r):
  if n >= r:
    numer = factorial(n) % mod
    denom_inv = pow(((factorial(r) % mod)* (factorial(n-r) % mod)), mod-2, mod)
    return (numer * denom_inv) % mod
  else:
    return 0


pp = [0]
div = 2
while M > 1:
    if pp[-1] != 0:
        pp.append(0)
    while M % div == 0:
        pp[-1] += 1
        M = M / div
    div += 1

ans = 1
for p in pp:
    ans = (ans * comb(N+p-1, p)) % mod

print(ans)

### FIXED CODE ###

from math import factorial

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


def comb(n,r):
  if n >= r:
    numer = factorial(n) % mod
    denom_inv = pow(((factorial(r) % mod)* (factorial(n-r) % mod)), mod-2, mod)
    return (numer * denom_inv) % mod
  else:
    return 0


pp = [0]
div = 2
while M > 1:
    if pp[-1] != 0:
        pp.append(0)
    while M % div == 0:
        pp[-1] += 1
        M = M / div
    div += 1

ans = 1
for p in pp:
    ans = (ans * comb(N+p-1, p)) % mod

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

N=int(input())
import math
for i in range(1,N+1):
    ans=0
    for x in range(1,33):
        for y in range(1,33):
            a=-(3*(x*x)+3*(y*y)+2*x*y)/4+i
            if a>0:
                b=(math.sqrt(a)-(x+y)/2)
                if b>0 and b%1==0.0:
                    ans+=1

    print(ans)



### FIXED CODE ###

N=int(input())
li=[0]*N
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            temp=x**2+y**2+z**2+x*y+y*z+z*x
            if temp<=N:
                li[temp-1]+=1
for i in range(N):
    print(li[i])
### BUGGY CODE ###

S = input()

res = 0
tmp = [0] * 2019
tmp[0] = 1
for i in range(1, len(S) + 1):
    tmp[(int(S[len(S) - i:]) % 2019)] += 1
    # print(S[len(S) - i:])

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)


### FIXED CODE ###

S = input()[::-1]

res = 0
tmp = [0] * 2019
tmp[0] = 1
sum_of_digits = 0
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    tmp[sum_of_digits] += 1

for t in tmp:
    res += (t * (t - 1)) // 2

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

from sys import stdin
readline = stdin.readline

N, M, Q = map(int, readline().split())

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, readline().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, readline().split())
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
print('\n'.join(str(v) for v in result))


### FIXED CODE ###

N, M, Q = map(int, input().split())

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
print('\n'.join(str(v) for v in result))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
def left(i):
    if i < 1:
        return 0
    return gcd(left(i-1), A[i-1])
def right(i):
    if i+1 > n-1:
        return 0
    return gcd(right(i+1), A[i+1]) 
ans = 0
for i in range(n):
    ans = max(ans, gcd(left(i), right(i)))
print(ans)

### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
L = [0]*n
R = [0]*n
for i in range(n-1):
    R [i+1] = gcd(R[i], A[i])
    L[i+1] = gcd(L[i], A[-i-1])
print(max(gcd(R[i], L[-i-1]) for i in range(n)))
### BUGGY CODE ###

import collections
import math
import numpy as np
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    pr = prime(ai[i])
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    for num,count in pr.items():
        kari *= pow(pow(num,count,mod),mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)


### FIXED CODE ###

import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)
    kari %= mod

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    kari *= pow(ai[i],mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)
### BUGGY CODE ###

n,a,b=map(int,input().split())
ans=0
while True:
    if n-a>=0:
        n-=a
        ans+=a
    else:
        ans+=n
        break
    n-=b
    if n<=0:
        break
print(ans)

### FIXED CODE ###

n,a,b=map(int,input().split())
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n
else:
    ans=a*(int(n/(a+b)))
    n=n%(a+b)
    while True:
        if n==0:
            break
        if n-a<0:
            ans+=n
            break
        else:
            ans+=a
            break

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

import copy
n = int(input())
all_list = [int(input()) for _ in range(n)]
max_value = max(all_list)
for i in range(n):
    if all_list[i] == max_value:
        tmp = copy.copy(all_list)
        tmp.pop(i)
        print(max(tmp))
    else:
        print(max_value)

### FIXED CODE ###

import copy
n = int(input())
all_list = [int(input()) for _ in range(n)]
max_value = max(all_list)
max_value_count = all_list.count(max_value)
for i in range(n):
    if all_list[i] == max_value:
        if max_value_count > 2:
            print(max_value)
        else:
            tmp = copy.copy(all_list)
            tmp.pop(i)
            print(max(tmp))
    else:
        print(max_value)
### BUGGY CODE ###

def data_input():
    D = int(input())
    C = tuple(map(int, input().split()))

    S = []
    for i in range(D):
        s = tuple(map(int, input().split()))
        S.append(s)

    return D, C, S


def score(D, C, S, T):
    """入力D, C, Sと出力Tからスコアを計算する関数"""

    last = [0] * 26  # 0で初期化されている

    def decrease(d):
        """d日めにiを開催した時の満足度の減少を返す関数"""
        res = 0
        base = sum(C)
        res -= base * (d + 1)
        for i in range(26):
            res += C[i] * last[i]
        return res

    V = []
    for d, i in enumerate(T):
        if d == 0:
            v = 0
        last[i] = d + 1
        v += S[d][i] + decrease(d)
        V.append(v)
    return V


D, C, S = data_input()

T = []
Cum_v = []
max_v = 0
for d in range(D):
    max_t = 0
    for i in range(26):
        v = score(d, C, S[:d+1], T+[i])[-1]
        if v >= max_v:
            # print(f'local_max at {d}-day is updated to {v}')
            max_t = i
            max_v = v
    T.append(max_t)
    print(max_t)

### FIXED CODE ###

D = 365

for i in range(D):
  print(1)