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

import math
from decimal import Decimal

X = int(input())
now = 100
year = 0

while True:
    if now >= X:
        break
    now_bad = int(now * Decimal(1.01))
    year += 1

print(year)


### FIXED CODE ###

import math
X = int(input())
now = 100

year = 0

while True:
    if now >= X:
        break
    now += now // 100
    year += 1

print(year)
### BUGGY CODE ###

import collections as cl
import numpy as np
n=int(input())
a=list(map(int,input().split()))

for k in range(n):
    b=a.copy()
    a.pop(k)
    a_=np.array(list(cl.Counter(a).values()))
    a=b
    c=np.sum(a_*(a_-1)/2)
    print(int(c))

### FIXED CODE ###

import collections as cl
import numpy as np
n=int(input())
a=list(map(int,input().split()))
b=cl.Counter(a)
a_=np.array(list(b.values()))
c=np.sum(a_*(a_-1)/2)
for k in range(n):
    x=b[a[k]]
    if x==2:
        print(int(c-1))
    elif x==1:
        print(int(c))
    else:
        print(int(c-(x-1)))
### BUGGY CODE ###

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

lst1 = [int(input()) for i in range(M)]

def fib(n):
  a, b = 1, 2
  for i in range(1,n+1):  
    if (i == 1):
      if (i in lst1):
        a, b = 0, 1
    else:
      if (i in lst1):
        a, b = 0, a
      else:
        a, b = b, b+a
  return a

print(fib(N)  % 1000000007)

### FIXED CODE ###

n,m=map(int,input().split())
D=[1] * (n + 1)
for _ in range(m):
    D[int(input())] = 0
for i in range(n+1):
    if i > 1:
        D[i] = (D[i-1] + D[i-2]) % 1000000007 * D[i]
print(D[i])
### BUGGY CODE ###

n = int(input())
an = [int(i) for i in input().split()]
lowe = 0
for i in range(0, n):
    an_sub = an[0:i + 1]
    if an_sub[i] <= min(an_sub):
        lowe += 1
print(lowe)

### FIXED CODE ###

n = int(input())
an = [int(i) for i in input().split()]
lowe, min_an_sub = 0, an[0]
an_sub = []
for i in range(0, n):
    an_sub.append(an[i])
    min_an_sub = min(min_an_sub, an[i])
    if an_sub[i] <= min_an_sub:
        lowe += 1
print(lowe)
### BUGGY CODE ###

from collections import defaultdict


def p_e():
    s = input()
    t = input()
    l = defaultdict(list)

    for i, c in enumerate(list(s)):
        l[c].append(i + 1)
    # 
    # for c in list(t):
    #     if c not in l.keys():
    #         print(-1)
    #         exit()

    N = 0
    current = 0
    for c in list(t):
        if not l[c]:
            print(-1)
            exit()

        if current >= l[c][-1]:
            current = l[c][0]
            N += 1
            continue

        for i in l[c]:
            if current < i:
                current = i
                break

    print(N * len(s) + current)


if __name__ == '__main__':
    p_e()


### FIXED CODE ###

from collections import defaultdict
from bisect import *


def p_e():
    s = input()
    t = input()
    l = defaultdict(list)

    for i, c in enumerate(list(s)):
        l[c].append(i + 1)

    for c in list(t):
        if c not in l.keys():
            print(-1)
            exit()

    N = 0
    current = -1
    for c in list(t):
        R = l[c]

        x = bisect(R, current)

        if len(R) == x:
            N += 1
            current = R[0]
        else:
            current = R[x]

    print(N * len(s) + current)


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

# AOTコンパイルテスト
import sys
import numpy as np
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def solve(dp,item):
    dptmp1 = np.copy(dp)
    dptmp2 = np.copy(dp)
    dptmp3 = np.copy(dp)
    for i in range(len(item)):
        dptmp3[item[i][0]:] = np.fmax(dptmp3[item[i][0]:], dptmp2[item[i][0]]+item[i][1])
        dptmp2[item[i][0]:] = np.fmax(dptmp2[item[i][0]:], dptmp1[item[i][0]]+item[i][1])
        dptmp1[item[i][0]:] = np.fmax(dptmp1[item[i][0]:], dp[item[i][0]]+item[i][1])
    return dptmp3


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
 
    cc = CC('my_module')
    cc.export('solve', '(i8[:],i8[:,:])')(solve)
    cc.compile()
    exit()

R, C, K = map(int, input().split())
items = defaultdict(list)
for _ in range(K):
    r, c, v = map(int, input().split())
    items[r-1].append([c-1, v])
dp = np.zeros(C, dtype='int64')
for RR in range(R):
    if items[RR]==[]:
        continue
    items[RR].sort(key=lambda x: x[0])
    dp=solve(dp,np.array(items[RR],dtype='int64'))
print(dp[-1])

### FIXED CODE ###

import sys
import numpy as np
from collections import defaultdict
from numba import njit
def input(): return sys.stdin.readline().rstrip()

@njit
def koushin(dp,item):
    dptmp1 = np.copy(dp)
    dptmp2 = np.copy(dp)
    dptmp3 = np.copy(dp)
    for i in range(len(item)):
        dptmp3[item[i][0]:] = np.fmax(dptmp3[item[i][0]:], dptmp2[item[i][0]]+item[i][1])
        dptmp2[item[i][0]:] = np.fmax(dptmp2[item[i][0]:], dptmp1[item[i][0]]+item[i][1])
        dptmp1[item[i][0]:] = np.fmax(dptmp1[item[i][0]:], dp[item[i][0]]+item[i][1])
    return dptmp3

def main():
    R, C, K = map(int, input().split())
    items = defaultdict(list)
    for _ in range(K):
        r, c, v = map(int, input().split())
        items[r-1].append([c-1, v])
    dp = np.zeros(C, dtype=int)
    for RR in range(R):
        if items[RR]==[]:
          continue
        items[RR].sort(key=lambda x: x[0])
        dp=koushin(dp,np.array(items[RR],dtype=int))
    print(dp[-1])


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

k = int(input())
def gcd1 (a, b):
    while True:
        if (a < b):
            a, b = b, a
        c = a%b
        if (c == 0):
            return (b)
        else:
            a = b
            b = c

def gcd2 (a, b, c):
    tmp = gcd1(a, b)
    ans = gcd1(tmp, c)
    return (ans)

count = 0
for i in range(k):
    for j in range(k):
        for l in range(k):
            tmp = gcd2(i + 1, j + 1, l + 1)
            count = count + tmp
print(count)


### FIXED CODE ###

k = int(input())
def gcd1 (a, b):
    while True:
        if (a < b):
            a, b = b, a
        c = a%b
        if (c == 0):
            return (b)
        else:
            a = b
            b = c

count = 0
for i in range(k):
    for j in range(k):
        tmp = gcd1(i + 1, j + 1)
        if (tmp == 1):
            count = count + k
        else:
            for l in range(k):
                tmp2 = gcd1(tmp, l + 1)
                count = count + tmp2

print(count)
### BUGGY CODE ###

N = int(input())
Stemp = str(input())
S = []
for i in range(N):
  temp = int(Stemp[i])
  S.append(temp)
#print(S)
#i桁目までみて、1文字目がx、2文字目がy、3文字目がzのがあるか
dp = [[0]*10 for _ in range(N+1)]
dpp = [[[0]*10 for _ in range(10)] for _ in range(N+1)]
dppp = [[[[0]*10 for _ in range(10)] for _ in range(10)] for _ in range(N+1)]

for i in range(N):
  now = S[i] #i桁目 1index
  #dp[i+1][now] = 1
  for x in range(10):
    if x == now:
      dp[i+1][x] = 1
      #print(dp[i+1][x])
    else:
      dp[i+1][x] = max(dp[i][x],dp[i+1][x])
    for y in range(10):
      if y == now and dp[i][x] == 1:
        dpp[i+1][x][y] = 1
      else:
        dpp[i+1][x][y] = max(dpp[i][x][y],dpp[i+1][x][y])
      for z in range(10):
        if z == now and dpp[i][x][y] == 1:
          dppp[i+1][x][y][z] = 1
        else:
          dppp[i+1][x][y][z] = max(dppp[i][x][y][z],dppp[i+1][x][y][z])
#print(dp)
#print(dpp)
#print(dppp)
ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      ans += dppp[N][i][j][k]
        
print(ans)       

### FIXED CODE ###

N = int(input())
Stemp = str(input())
S = []
for i in range(N):
  temp = int(Stemp[i])
  S.append(temp)
ans = set([])
L = [[] for _ in range(10)]
for i in range(N):
  L[S[i]].append(i)
#print(L)
for v in range(1000):
  a = v//100
  b = (v-a*100)//10
  c = v-a*100-b*10
  if not L[a]:
    continue
  left = min(L[a])
  Flag = False
  for x in L[b]:
    if x > left:
      mid = x
      Flag = True
      break
  if not Flag:
    continue
  Flag = False
  for y in L[c]:
    if y > mid:
      right = y
      Flag = True
      break
  if not Flag:
    continue
  ans.add(v)
  #print(v,left,mid,right)
print(len(ans))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, t = map(int, input().split())
    ab = []
    for _ in range(n):
        a, b = map(int, input().split())
        ab.append((a, b))
    ab.sort()
    dp = [0] * (t + 1)
    for a, b in ab:
        dp[t] = max(dp[t], dp[t - 1] + b)
        for i in range(t - 1, a - 1, -1):
            dp[i] = max(dp[i], dp[i - a] + b)
    print(dp[t])
    # print(dp)

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, t = map(int, input().split())
    ab = []
    for _ in range(n):
        a, b = map(int, input().split())
        ab.append((a, b))
    ab.sort()
    dp = [0] * (t + 1)
    for a, b in ab:
        mx = 0
        for i in range(t - 1, -1, -1):
            dpi = dp[i]
            if dpi > mx: mx = dpi
            if i - a >= 0:
                dp[i] = max(dpi, dp[i - a] + b)
        dp[t] = max(dp[t], mx + b)
    print(dp[t])
    # print(dp)

main()
### BUGGY CODE ###

import bisect


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

    s = [0, N+1]
    order = [0]*(N+1)

    for i in range(N):
        order[a[i]] = i+1

    ans = 0
    for i in range(1, N+1):
        bisect.insort_left(s, order[i])
        ans += i*(order[i]-s[bisect.bisect_left(s, order[i])-1]) * \
            (s[bisect.bisect_left(s, order[i])+1]-order[i])
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

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

order = [0]*(N+1)

for i in range(N):
    order[a[i]] = i

ans = 0
checkR = list(range(N+1))
checkL = list(range(N+1))

for i in range(N, 0, -1):
    ans += i*(order[i] - checkR[order[i]] + 1)*(checkL[order[i]] - order[i]+1)
    checkR[checkL[order[i]]+1] = checkR[order[i]]
    checkL[checkR[order[i]]-1] = checkL[order[i]]
print(ans)
### BUGGY CODE ###

n=int(input())
h=list(map(int,input().split()))
x=[0]*n

for i in range(n-1):
  t=0
  H=h[i]
  
  for j in range(i+1,n):
    if h[j]<=H: 
      H=h[j]
      t+=1
    else:
      break
  x[i]=t

print(str(max(x)))
    

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
b=[0]*n

for i in range(n-1):
  b[i]=h[i]-h[i+1]
  if b[i]>=0:
    b[i]=1
  else:
    b[i]=0
b=[str(x) for x in b]
c="".join(b)
d=c.split("0")
print(len(max(d)))
### BUGGY CODE ###

#! /usr/bin/env python3

def f(c, bw):
    r = ""
    b = 1
    if bw[0] != c:
        for i in bw:
            if b and i != c:
                r += c
            else:
                b = 0
                r += i
        return 1, r
    elif bw[-1] != c:
        for i in bw[::-1]:
            if b and i != c:
                r += c
            else:
                b = 0
                r += i
        return 1, r
    return 0, bw
    

bw = input()
cnt = 0
c = ('B', 'W')
while ('B' in bw) and ('W' in bw):
    a = c[cnt%2]
    b, bw = f(a, bw)
    cnt += b
print(cnt)

### FIXED CODE ###

#! /usr/bin/env python3

bw = input()
cnt = 0
t = bw[0]
for i in bw[1:]:
    if i != t:
        cnt += 1
        t = i
print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

anslist = []
ans = 0

for i in range(1000):
    if i < 10:
        chk = '00' + str(i)
    elif i < 100:
        chk = '0' + str(i)
    else:
        chk = str(i)

    for j in range(len(s)):
        if s[j] == chk[0]:
            for k in range(j+1, len(s)):
                if s[k] == chk[1]:
                    for l in range(k+1, len(s)):
                        if s[l] == chk[2]:
                            # print(chk)
                            anslist.append(chk)
            continue
ans = len(set(anslist))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    x = s.find(i[0])
    y = s.find(i[1], x+1)
    z = s.find(i[2], y+1)
    if x != -1 and y != -1 and z != -1:
        ans += 1
print(ans)
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = {}
ind = 0
from collections import defaultdict
ns = defaultdict(list)
for i in range(n):
    for j in range(i+1,n):
        index[i,j] = ind
        index[j,i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i,a[i][j]]
        v = index[i,a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u, pos):
    # uからdfs
    seen[u] = True
    ans = -float("inf")
    for v in ns[u]:
        if done[v]:
            ans = max(ans, vals[v]+1)
            continue
        elif seen[v]:
            # サイクルを検出
            pos = v
            return pos
        else:
            pos = dfs(v, pos)
            if pos>=0:
                return pos
            ans = max(ans, vals[v]+1)
    done[u] = True
    if ans==-float("inf"):
        ans = 0
    vals[u] = ans
    return pos
ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u, -1)
    if pos>=0:
        print(-1)
        break
else:
    print(max(vals)+1)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = {}
ind = 0
from collections import defaultdict
ns = defaultdict(list)
for i in range(n):
    for j in range(i+1,n):
        index[i,j] = ind
        index[j,i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i,a[i][j]]
        v = index[i,a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u):
    # uからdfs
    seen[u] = True
    ans = 0
    for v in ns[u]:
        if done[v]:
            ans = max(ans, vals[v]+1)
            continue
        elif seen[v]:
            # サイクルを検出
            return 1
        else:
            pos = dfs(v)
            if pos>=0:
                return 1
            ans = max(ans, vals[v]+1)
    done[u] = True
    vals[u] = ans
    return -1
ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u)
    if pos>=0:
        print(-1)
        break
else:
    print(max(vals)+1)
### BUGGY CODE ###

n = int(input())
s = input()
res = 0
for i in range(1000):
    tmp = str(i).rjust(3, '0')
    state = 0
    for j in range(n):
        if state == 3:
            continue
        elif s[j] == tmp[state]:
            state += 1
    else:
        if state==3:
            res += 1
print(res)

### FIXED CODE ###


n = int(input())
s = input()

lst = [[] for i in range(10)]

for i in range(n):
    c = int(s[i])
    lst[c].append(i)

done = []
cnt = 0
for x in range(0,1000):
    tmp = str(x).rjust(3,'0')
    c1,c2,c3 = int(tmp[0]),int(tmp[1]),int(tmp[2])
    
    mi = -1
    mx = -1
    if len(lst[c1]) != 0:
        mi = lst[c1][0]
    if len(lst[c3]) != 0:
        mx = lst[c3][-1]
    
    if mi >= 0 and mx >= 0:
        for y in lst[c2]:
            if mi < y < mx:
                done.append(tmp)
    else:
        continue
        

print(len(set(done)))
### BUGGY CODE ###

def resolve():
    '''
    code here
    '''
    from collections import deque

    H, W = [int(item) for item in input().split()]
    Ch, Cw = [int(item)-1 for item in input().split()]
    Dh, Dw = [int(item)-1 for item in input().split()]
    grid = [input() for _ in range(H)]
    max_num = 10**6
    fp = [[max_num for _ in range(W)] for _ in range(H)]

    que = deque([[Ch, Cw, 0]])
    fp[Ch][Cw] = 0

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while que:
        y, x, w_num = que.popleft()

        for dy, dx in walk:
            ny = y + dy
            nx = x + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1 and grid[ny][nx] == '.' and fp[ny][nx] > w_num:
                que.appendleft([ny, nx, w_num])
                fp[ny][nx] = w_num

        for dy, dx in warp:
            ny = y + dy
            nx = x + dx
            nw = w_num +1

            if 0 <= ny <= H-1 and 0 <= nx <= W-1 and grid[ny][nx] == '.' and fp[ny][nx] > nw:
                que.append([ny, nx, nw])
                fp[ny][nx] = nw

    if fp[Dh][Dw] != max_num:
        print(fp[Dh][Dw])
    else:
        print(-1)

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    from collections import deque

    H, W = [int(item) for item in input().split()]
    Ch, Cw = [int(item)-1 for item in input().split()]
    Dh, Dw = [int(item)-1 for item in input().split()]
    grid = [input() for _ in range(H)]
    max_num = 10**6
    fp = [[max_num] * W for _ in range(H)]

    que = deque([[Ch, Cw, 0]])
    fp[Ch][Cw] = 0

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while que:
        y, x, w_num = que.popleft()

        for dy, dx in walk:
            ny = y + dy
            nx = x + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1 and grid[ny][nx] == '.' and fp[ny][nx] > w_num:
                que.appendleft([ny, nx, w_num])
                fp[ny][nx] = w_num

        for dy, dx in warp:
            ny = y + dy
            nx = x + dx
            nw = w_num +1

            if 0 <= ny <= H-1 and 0 <= nx <= W-1 and grid[ny][nx] == '.' and fp[ny][nx] > nw:
                que.append([ny, nx, nw])
                fp[ny][nx] = nw

    if fp[Dh][Dw] != max_num:
        print(fp[Dh][Dw])
    else:
        print(-1)

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

# coding:utf-8

import sys
from collections import Counter, defaultdict, deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


H, W = LI()
B = [[1 if s == '#' else 0 for s in S()] for _ in range(H)]


dy = (0, -1, 0, 1)
dx = (1, 0, -1, 0)
def BFS(i, j):
    ans = 0
    queue = deque([(i, j)])
    visited = set()
    while queue:
        y, x = queue.pop()
        color = B[y][x]
        if color == 0 and (y, x) not in visited:
            # print(y, x)
            ans += 1
        visited.add((y, x))
        for k in range(4):
            ny = y + dy[k]
            nx = x + dx[k]
            if (ny, nx) in visited:
                continue

            if ny < 0 or ny >= H or nx < 0 or nx >= W:
                continue

            if B[ny][nx] == color:
                continue

            queue.append((ny, nx))

    return ans


ans = 0
for h in range(H):
    for w in range(W):
        if B[h][w] == 1:
            ans += BFS(h, w)

print(ans)


### FIXED CODE ###

# coding:utf-8

import sys
from collections import Counter, defaultdict, deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


H, W = LI()
B = [[1 if s == '#' else 0 for s in S()] for _ in range(H)]


dy = (0, -1, 0, 1)
dx = (1, 0, -1, 0)

def BFS(i, j):
    ans = 0
    queue = deque([(i, j)])
    visited = set()
    visited_b = set()
    while queue:
        y, x = queue.pop()
        color = B[y][x]
        if color == 0 and (y, x) not in visited:
            # print(y, x)
            ans += 1
        if color == 1:
            visited_b.add((y, x))
        visited.add((y, x))
        for k in range(4):
            ny = y + dy[k]
            nx = x + dx[k]
            if (ny, nx) in visited:
                continue

            if ny < 0 or ny >= H or nx < 0 or nx >= W:
                continue

            if B[ny][nx] == color:
                continue

            queue.append((ny, nx))

    return ans, visited_b


ans = 0
visited_b = set()
for h in range(H):
    for w in range(W):
        if B[h][w] == 1 and (h, w) not in visited_b:
            tmp, v = BFS(h, w)
            ans += tmp * len(v)
            visited_b |= v
            # print(ans, v)

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

N = int(input())
A = [int(a) for a in input().split()]

ans = 1

for a in range(0,N):
	ans = ans * A[a]


if ans > 10 ** 18:
	ans = -1

print(ans)

### FIXED CODE ###

N = int(input())
#A = [int(a) for a in input().split()]
#A = input().split()
A = list(map(int,input().split()))

ans = 1

if 0 in A:
	print(0)
else:
	for a in range(N):
		ans = ans * A[a]

		if ans > (10 ** 18):
			ans = -1
			break
	print(ans)
### BUGGY CODE ###

import itertools
Q = int(input())
l, r = [0]*Q, [0]*Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
lr = zip(l,r)

def Is_prime(n):
    # nが1以下ならFalse
    if n<=1:
        return False
    # nが2または3ならTrue
    if n==2 or n==3:
        return True
    # nが2の倍数ならFalse
    if n%2==0:
        return False
    # nの平方根を整数で取得
    sqrt_root = int(n**.5)
    # nがnの平方根以下の3以上の奇数で1回でも割れたらFalse
    for i in range(3,sqrt_root+1,2):
        if n%i==0:
            return False
    # 上の条件を全てぬけたものはTrue
    return True

def Prime_table(n):
    res = []
    for i in range(n+1):
        if Is_prime(i):
            res.append(i)
    return res

def is_like(x):
    ptb = Prime_table(x)
    if x in ptb and (x+1)//2 in ptb:
        return 1
    return 0


for l,r in lr:
    L = list(itertools.accumulate(list(map(is_like,range(r+1)))))
    print(L[r]-L[l-1])

### FIXED CODE ###

MAX = 101010
is_prime = [1]*MAX
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,MAX):
    if not is_prime:
        continue
    for j in range(i*2,MAX,i):
        is_prime[j] = 0

a = [0]*MAX
for i in range(MAX):
    if i%2==0:
        continue
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] = 1


s = [0]*(MAX+1)
for i in range(MAX):
    s[i+1] = s[i] + a[i]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(s[r+1]-s[l])
### BUGGY CODE ###

S = list(input())

count = 0
for i in range(len(S)):
    for j in range(len(S)-1, i, -1):
        if S[j] == "W" and S[j-1] == "B":
            S[j], S[j-1] = S[j-1], S[j]
            count += 1

print(count)

### FIXED CODE ###

S = input()

ans = 0
countB = 0
for i in range(len(S)):
    if S[i] == "W":
        ans += countB
    elif S[i] == "B":
        countB += 1
print(ans)
### BUGGY CODE ###


def func(n, a):
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		# print(tmp[i])s
	if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

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

### FIXED CODE ###

def func(n, a):
	if(0 in a):
		return 0
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

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