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


def main():
    N = int(input())
    s = list(input())

    cnt = 0
    prej = N
    for i in range(N):
        if s[i] == "R":
            continue
        if i >= prej:
            break
        for j in list(range(i+1,prej))[::-1]:
            if s[j] == "W":
                continue
            if i >= j:
                break
            cnt += 1 
            prej = j
            break
    print(cnt)

if __name__ == "__main__":
    main()


### FIXED CODE ###


N = int(input())
s = list(input())

reds = 0
for c in s:
    reds += 1 if c == "R" else 0

whites = 0
for i in range(reds):
    whites += 1 if s[i] == "W" else 0

print(whites)
### BUGGY CODE ###

from  fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
ans=1
for i in range(N-1):
    R.append(gcd(R[-1], A[::-1][i]))
    L.append(gcd(L[-1], A[i]))
print(max(gcd(l,r)for l,r in zip(L,R[::-1])))

### FIXED CODE ###

from  fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
ans=1
for i in range(N-1):
    R.append(gcd(R[-1], A[-1-i]))
    L.append(gcd(L[-1], A[i]))
print(max(gcd(l,r)for l,r in zip(L,R[::-1])))
### BUGGY CODE ###

n = int(input())
re =1

list = [int(s) for s in input().split()]
  
for i in range(n):
    re *= list[i]
    
if(re > 1000000000000000000):
    print("-1")
else:
    print(re)

### FIXED CODE ###

n =int(input())
limit = 10**18
re =1
 
l = list(map(int, input().split()))
 
l.sort()
#print(l)
if(l[0] == 0):
    re = 0
else:
  for i in l:
    re *= i
    #print(re)
    if(re > limit):
      re = -1
      break
print(re)
### BUGGY CODE ###

#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)

#enumerate input

def main():
    *s,=map(len,input().split("T"))
    x,y=map(int,input().split())
    start=str(s[0])
    n=[0]+s[2::2]
    m=[0]+s[1::2]
    flag1=0
    flag2=0
#    print(n,m)
    for i in range(2**len(n)):
        if x==eval(start+"".join(["+","-"][i>>j&1]+str(n[j-1])for j in range(len(n)))):
            flag1=1
            break
    for i in range(2**len(m)):
        if y==eval("".join(["+","-"][i>>j&1]+str(m[j-1])for j in range(len(m)))):
            flag2=1
            break
    if flag1 and flag2:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

### FIXED CODE ###

#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)

def main():
    *s,=map(len,input().split("T"))
    x,y=map(int,input().split())
    start=s[0]
    n=s[2::2]
    m=s[1::2]
#    print(n,m)
    dx={start}
    dy={0}
#    print(dx)
    for i in n:
        dx={r+j for j in dx for r in{-i,i}}
#        print(dx)
    for i in m:
        dy={r+j for j in dy for r in{-i,i}}
#        print(dy)
    if x in dx and y in dy:
        print("Yes")
    else:
        print("No")


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

N = int(input())

student_list = input().rstrip().split(' ')

answer = ""

for n in range(1, N+1):
  i = student_list.index(str(n))
  answer += str(i+1) + " "
  
print(answer[0:-1])


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i, a in enumerate(A):
    ans[a-1] = i+1

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

def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                if j - i == k - j:
                    continue
                if (S[i] != S[j]) and (S[i] != S[k]) and (S[j] != S[k]):
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    R, G, B = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
    for i in range(N - 1, -1, -1):
        R[i], G[i], B[i] = R[i + 1], G[i + 1], B[i + 1]
        if S[i] == 'R':
            R[i] += 1
        elif S[i] == 'G':
            G[i] += 1
        else:
            B[i] += 1
    ans = 0
    for i in range(N):
        for j in range(i + 1, N - 1):
            if S[i] == S[j]:
                continue
            if j + (j - i) + 1 < N + 1:
                if S[i] + S[j] == 'RG':
                    ans += B[j + 1]
                    if B[j + (j - i) + 1] != B[j + (j - i)]:
                        ans -= 1
                elif S[i] + S[j] == 'GR':
                    ans += B[j + 1]
                    if B[j + (j - i) + 1] != B[j + (j - i)]:
                        ans -= 1
                elif S[i] + S[j] == 'RB':
                    ans += G[j + 1]
                    if G[j + (j - i) + 1] != G[j + (j - i)]:
                        ans -= 1
                elif S[i] + S[j] == 'BR':
                    ans += G[j + 1]
                    if G[j + (j - i) + 1] != G[j + (j - i)]:
                        ans -= 1
                elif S[i] + S[j] == 'GB':
                    ans += R[j + 1]
                    if R[j + (j - i) + 1] != R[j + (j - i)]:
                        ans -= 1
                elif S[i] + S[j] == 'BG':
                    ans += R[j + 1]
                    if R[j + (j - i) + 1] != R[j + (j - i)]:
                        ans -= 1
            else:
                if S[i] + S[j] == 'RG':
                    ans += B[j + 1]
                elif S[i] + S[j] == 'GR':
                    ans += B[j + 1]
                elif S[i] + S[j] == 'RB':
                    ans += G[j + 1]
                elif S[i] + S[j] == 'BR':
                    ans += G[j + 1]
                elif S[i] + S[j] == 'GB':
                    ans += R[j + 1]
                elif S[i] + S[j] == 'BG':
                    ans += R[j + 1]
    print(ans)


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

N = int(input())

ans = list()
for i in range(1, N+1):
    for j in range(1, N+1): 
        if i * j == N:
            ans.append(i + j -2) 
        else:
             pass

print(min(ans))

### FIXED CODE ###

import math
N = int(input())

ans = list()
for i in range(int(math.sqrt(N))):
    i += 1
    if N % i ==0:
        j = N//i
        ans.append(i + j -2) 
    else:
        pass

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

S = input()
ans = 0
for i in range(len(S)):
    for j in range(2020):
        if i+j+1 > len(S): break
        if int(S[i:i+j+1]) % 2019 == 0:
            ans += 1
print(ans)

### FIXED CODE ###

S = input()
r = 1
arr = [0]
for c in S[::-1]:
    arr.append((arr[-1] + int(c) * r) % 2019)
    r *= 10
    r %= 2019
from collections import Counter
ctr = Counter(arr)
ans = 0
for v in ctr.values():
    ans += v*(v-1)//2
print(ans)
### BUGGY CODE ###

import itertools
n = int(input())
a = list(map(int,input().split()))
arr = [0]
arr += list(itertools.accumulate(a))
ans = 0

_set = set(arr)
for i in _set:
    c = arr.count(i)
    ans += (c * (c - 1)) // 2

print(ans)


### FIXED CODE ###

import itertools
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
arr = [0]
arr += list(itertools.accumulate(a))
ans = 0

c = Counter(arr)
for v in c.values():
    if v > 1:
        ans += v * (v - 1) // 2

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

n= int(input())
items=[]
for i in range(n):
    s=input()
    if s not in items:
        items.append(s)
print(len(items))


### FIXED CODE ###

n= int(input())
items={}
for i in range(n):
    s=input()
    items[s]=0
print(len(items))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
hL = list(map(int, input().split()))

for i in range(n):
    if hL[i] !=min(hL[i:n]):
        hL[i]-=1
if hL ==sorted(hL):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys
import numpy as np
input = sys.stdin.readline
n = int(input())

L = np.array(list(map(int, input().split())))

for i in range(n-1, 0, -1):
    if L[i]-L[i-1] ==-1:
        L[i-1] -=1

if np.all(L ==sorted(L)):
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    i = 7
    while True:
        if i % k == 0:
            print(len(str(i)))
            break
        i *= 10
        i += 7


### FIXED CODE ###

from itertools import count

k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    m = 0
    for i in count(0):
        m += pow(10, i, k) * 7
        m %= k
        if m == 0:
            print(i+1)
            break
### BUGGY CODE ###

#!/usr/bin/env python3


def solve(H, W, S):
    grid = [0] * (W * H)
    for y in range(H):
        count = 0
        start = 0
        yw = y * W
        for x in range(W):
            if S[y][x] == '#':
                for i in range(start, x):
                    grid[yw+i] = count
                start = x + 1
                count = 0
            else:
                count += 1
        for i in range(start, W):
            grid[yw+i] = count

    ans = 1
    for x in range(W):
        count = 0
        start = 0
        for y in range(H):
            if S[y][x] == '#':
                for i in range(start, y):
                    if ans < grid[i*W+x] + count:
                        ans = grid[i*W+x] + count
                start = y + 1
                count = 0
            else:
                count += 1
        for i in range(start, H):
            if ans < grid[i*W+x] + count:
                ans = grid[i*W+x] + count

    return ans - 1


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [input().strip() for _ in range(H)]

    ans = solve(H, W, S)

    print(ans)


### FIXED CODE ###

#!/usr/bin/env python3


def solve(H, W, S):
    grid = [[0] * W for _ in range(H)]
    for y in range(H):
        count = 0
        start = 0
        for x in range(W):
            if S[y][x] == '#':
                for i in range(start, x):
                    grid[y][i] = count
                start = x + 1
                count = 0
            else:
                count += 1
        for i in range(start, W):
            grid[y][i] = count

    for x in range(W):
        count = 0
        start = 0
        for y in range(H):
            if S[y][x] == '#':
                for i in range(start, y):
                    grid[i][x] += count
                start = y + 1
                count = 0
            else:
                count += 1
        for i in range(start, H):
            grid[i][x] += count

    ans = 0
    for x in range(W):
        for y in range(H):
            if grid[y][x] > ans:
                ans = grid[y][x]
    return ans - 1


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [input().strip() for _ in range(H)]

    ans = solve(H, W, S)

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

# BFS
from collections import deque
import numpy as np
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
# 頂点数と辺数
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
# 全頂点を未訪問に初期化
dist = [[-1] * W for _ in range(H)]

ans = float('inf')
que = deque()
for h in range(H):
    for w in range(W):
        if A[h][w] == '#':
            que.append([h, w])
            dist[h][w] = 0

# bfs開始 (キューが空になるまで探索を行う)
while len(que) > 0:
    v = que.popleft()  # キューから先頭頂点を取り出す
    for i in range(4):
        nx = v[0] + dx[i]
        ny = v[1] + dy[i]
        if (0 <= nx and nx < H and 0 <= ny and ny < W and A[nx][ny] != '#' and dist[nx][ny] == -1):
            que.append([nx, ny])
            dist[nx][ny] = dist[v[0]][v[1]] + 1
print(np.max(dist))

### FIXED CODE ###

# BFS
from collections import deque


def main():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    # 頂点数と辺数
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    # 全頂点を未訪問に初期化
    dist = [[-1] * W for _ in range(H)]

    ans = float('inf')
    que = deque()
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                que.append([h, w])
                dist[h][w] = 0

    # bfs開始 (キューが空になるまで探索を行う)
    while len(que) > 0:
        v = que.popleft()  # キューから先頭頂点を取り出す
        for i in range(4):
            nx = v[0] + dx[i]
            ny = v[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W and dist[nx][ny] == -1):
                que.append([nx, ny])
                dist[nx][ny] = dist[v[0]][v[1]] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, dist[h][w])
    print(ans)


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

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, M = map(int, input().split(" "))
	N += 1
	a = []
	for i in range(M):
		tmp = int(input())
		tmp += 1
		a.append(tmp)
		if i != 0 and tmp == a[-1]+1:
			print(0)
			sys.exit()
			
	DP = [0 for i in range(N)]
	for i in range(N):
		if i == 0:
			DP[0] = 1
			continue
		if N-i in a:
			continue
		tmp = 0
		if i == 1:
			DP[i] = DP[i-1] % 1000000007
		if i > 1:
			DP[i] = (DP[i-2] + DP[i-1]) % 1000000007
		
	#print(DP)
	print(DP[-1])
	
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
import numpy as np
MOD = 1000000007
def main():
    n, m = [int(x) for x in input().split()]
    pattern = [1]
    broken = -1
    brokencnt = 0
    if brokencnt < m:
        broken = int(input())
        brokencnt += 1
    for i in range(1, n + 1):
        if i == broken:
            pattern.append(0)
            if brokencnt < m:
                broken = int(input())
                brokencnt += 1
            continue
        if i == 1:
            pattern.append(pattern[i - 1])
        if i > 1:
            pattern.append((pattern[i - 1] + pattern[i - 2]) % MOD)
    print(pattern[n])
main()
### BUGGY CODE ###

import numpy as np
n, k, q = map(int,input().split())
p = np.array([k]).repeat(n)

for i in range(q):
  tmp = int(input())
  p-=1
  p[tmp-1]+=1

for j in range(n):
  print('Yes' if p[j]>=1 else 'No')

### FIXED CODE ###

n, k, q = map(int,input().split())
p = [k-q]*n

for i in range(q):
  tmp = int(input())
  p[tmp-1]+=1

for ans in p:
  print('Yes' if ans>=1 else 'No')
### BUGGY CODE ###

n, k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])
print(min([max(h[x:x+k]) - min(h[x:x+k]) for x in range(n-k+1)]))


### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
h = np.array([int(input()) for _ in range(n)],dtype=int)
h.sort()
print(min([h[x+k-1] - h[x] for x in range(n-k+1)]))
### BUGGY CODE ###

import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nms = lambda: map(str, sys.stdin.readline().split())
nl = lambda: list(nm())

n, k = nm()
h = nl()
h.insert(0, h[0])
INF = 10 ** 9
dp = [INF for _ in range(n + 1)]
dp[1] = 0

for i in range(1, n + 1):
    for j in range(1, k + 1):
        if i + j <= n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
print(dp[-1])


### FIXED CODE ###

import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nms = lambda: map(str, sys.stdin.readline().split())
nl = lambda: list(nm())

n, k = nm()
h = nl()
h.insert(0, h[0])
INF = 10 ** 9
dp = [INF for _ in range(n + 1)]
dp[1] = 0

for i in range(2, n + 1):
    x = max(i - k, 1)
    dp[i] = min([d + abs(h[i] - hd) for d, hd in zip(dp[x:i], h[x:i])])
print(dp[-1])
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)
### BUGGY CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**9 + 10

for i in range(A):
    for j in range(B):
        num = a[i] + b[j]
        if num < ans:
            ans = num

for m in range(M):
    x, y, c = list(map(int, input().split()))
    calc = a[x-1] + b[y-1] - c
    if calc < ans:
        ans = calc

print(ans)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**9 + 10

num = min(a) + min(b)
if num < ans:
    ans = num

for m in range(M):
    x, y, c = list(map(int, input().split()))
    calc = a[x-1] + b[y-1] - c
    if calc < ans:
        ans = calc

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

S = input()
T = input()

out_str = "Yes"
for i in range(len(S)) :
	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		continue
	out_str = "No"
	break

print(out_str)

### FIXED CODE ###

S = input()
T = input()

out_str = "Yes"

indexes_s_all = []
indexes_t_all = []
for i in range(26) :
	c = chr(ord('a') + i)
	indexes_s = [n for n, x in enumerate(list(S)) if x == c]
	indexes_t = [n for n, x in enumerate(list(T)) if x == c]
	indexes_s_all.append(indexes_s)
	indexes_t_all.append(indexes_t)

indexes_s_all.sort()
indexes_t_all.sort()
if (indexes_s_all == indexes_t_all) :
	print("Yes")
else :
	print("No")
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
c1 += 1
c2 += 1
d1 += 1
d2 += 1
S = ["#"*(W+4)]*2 + ["##"+input()+"##" for _ in range(H)] + ["#"*(W+4)]*2

ans = [[10000000]*(W+4) for _ in range(H+4)]
ans[c1][c2] = 0
q = deque([[c1, c2]])

x = [[-1, 0], [0, -1], [0, 1], [1, 0]]

while q:
    h, w = q.popleft()
    
    for a, b in x:
        nh = h+a
        nw = w+b
        if S[nh][nw] == ".":
            if ans[nh][nw] > ans[h][w]:
                ans[nh][nw] = ans[h][w]
                q.appendleft([nh, nw])
    
    for a in range(-2, 3):
        for b in range(-2, 3):
            nh = h+a
            nw = w+b
            if S[nh][nw] == ".":
                if ans[nh][nw] > ans[h][w]+1:
                    ans[nh][nw] = ans[h][w]+1
                    q.append([nh, nw])

if ans[d1][d2] == 10000000:
    print(-1)
else:
    print(ans[d1][d2])

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
c1 += 1
c2 += 1
d1 += 1
d2 += 1
S = ["#"*(W+4)]*2 + ["##"+input()+"##" for _ in range(H)] + ["#"*(W+4)]*2

ans = [[10000000]*(W+4) for _ in range(H+4)]
ans[c1][c2] = 0
q = deque([[c1, c2]])

x = [[-1, 0], [0, -1], [0, 1], [1, 0]]

while q:
    h, w = q.popleft()
    
    for a, b in x:
        nh = h+a
        nw = w+b
        if S[nh][nw] == ".":
            if ans[nh][nw] > ans[h][w]:
                ans[nh][nw] = ans[h][w]
                q.appendleft([nh, nw])
    
    for a in range(-2, 3):
        for b in range(-2, 3):
            nh = h+a
            nw = w+b
            if S[nh][nw] == ".":
                if ans[nh][nw] > ans[h][w]+1:
                    ans[nh][nw] = ans[h][w]+1
                    q.append([nh, nw])

if ans[d1][d2] == 10000000:
    print(-1)
else:
    print(ans[d1][d2])
### BUGGY CODE ###

n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
l.sort()
a,b = [list(i) for i in zip(*l)]
z = []
for i in range(m):
    if a[i] == 1:
        x = b[i]
        for j in range(i+1,m):
            if x == a[j]:
                if n == b[j]:
                    print('POSSIBLE')
                    exit(0)
            elif x >= a[j]:
                pass
            else:
                break
    else:
        break
print('IMPOSSIBLE')

### FIXED CODE ###

n,m = map(int,input().split())
a = [] # 1 → x
z = [] # x → n
an = 0
zn = 0
for i in range(m):
    x,y = map(int,input().split())
    if x == 1:
        zn += 1
        z.append(y)
    elif y == n:
        an += 1
        a.append(x)
    else:
        pass
a.sort()
z.sort()
i = 0
j = 0
while i < an and j < zn:
    if a[i] == z[j]:
        print('POSSIBLE')
        exit(0)
    else:
        if a[i] > z[j]:
            j += 1
        else:
            i += 1
print('IMPOSSIBLE')
### BUGGY CODE ###

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

cnt = 0

for i in range(n):
    if p[i] == min(p[:i+1]):
        cnt += 1
print(cnt)

### FIXED CODE ###

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

cnt = 0
x = p[0]

for i in range(n):
    if p[i] <= x:
        cnt += 1
    x = min(x, p[i])
print(cnt)
### BUGGY CODE ###

MOD = 1000000007
S = input()
memo = [[0] * 13 for i in range(len(S)+1)]
memo[0][0] = 1

modmemo = []
modmemo.append(1)
for idx in range(len(S)):
	modmemo.append((modmemo[len(modmemo) - 1] * 10) % 13)


for idx in range(len(S)):
	ch = S[idx]
	if(ch == '?'):
		for num in range(10):
			mod = (modmemo[len(S) - idx - 1] * num)%13
			for i in range(13):
				if(memo[idx][i] > 0):
					memo[idx+1][(i+mod)%13] += memo[idx][i] 
					memo[idx+1][(i+mod)%13] %= MOD
	else:
		num = int(ch)
		mod = (modmemo[len(S) - idx - 1] * num)%13
		for i in range(13):
			if(memo[idx][i] > 0):
				memo[idx+1][(i+mod)%13] += memo[idx][i] 
				memo[idx+1][(i+mod)%13] %= MOD

print(memo[len(S)][5]%MOD)

### FIXED CODE ###

MOD = 1000000007
S = input()
memo = [[0] * 13 for i in range(len(S)+1)]
memo[0][0] = 1

for idx in range(len(S)):
	ch = S[idx]
	if(ch == '?'):
		for num in range(10):
			for i in range(13):
				if(memo[idx][i] > 0):
					memo[idx+1][(i*10+num)%13] += memo[idx][i] 
	else:
		num = int(ch)
		for i in range(13):
			if(memo[idx][i] > 0):
				memo[idx+1][(i*10+num)%13] += memo[idx][i] 
	
	for i in range(13):
		memo[idx+1][i] %= MOD

print(memo[len(S)][5]%MOD)
### BUGGY CODE ###



def gcd_core(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g


def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    if len(arr) == 1:
        return arr[0]
    else:
        newl = []
        ind = 0
        while True:
            if ind + 1 < len(arr):
                newl.append(lcm_core(arr[ind],arr[ind+1]))
                ind += 2
            else:
                newl.append(arr[ind])
                ind += 1
            if ind >= len(arr):
                break
        return lcm(newl)


n = int(input())

if n == 1:
    print(1)
else:
    arr = list(map(int,input().split()))
    l = lcm(arr)
    m = 10**9+7
    # print(l)
    # buf = []
    # for i in range(n):
    #     buf.append(l/arr[i])
    # print(buf)
    ans = 0
    for i in range(n):
        ans += l//arr[i]
        ans %= m
    print(ans)


### FIXED CODE ###

import fractions
from functools import reduce

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

def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = tuple(map(int, input().split()))

mod = 10 ** 9 + 7

l = lcm_list(A)

ans = 0

for i in range(N):
  ans += l // A[i]

ans = ans % mod

print(ans)