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

N, Q = map(int, input().split())
s = input()
for _ in range(Q):
  l, r = map(int, input().split())
  print(s.count('AC', l-1, r))

### FIXED CODE ###

import sys
import bisect

N, Q = map(int, input().split())
s = sys.stdin.readline().rstrip()
ac_list = []
start = 0
while True:
  index = s.find('AC', start)
  if index == -1:
    break
  ac_list.append(index + 1)
  start = index + 1


for _ in range(Q):
  l, r = map(int, input().split())
  res = 0
  start = bisect.bisect_left(ac_list, l)
  end = bisect.bisect_right(ac_list, r-1) - 1
  print(end-start+1)
### BUGGY CODE ###

s = input()
ans = 0
flg = 0
while flg == 0:
    ans += s.count('01') * 2
    s = s.replace('01', '')
    ans += s.count('10') * 2
    s = s.replace('10', '')
    if not ('10' in s or '01' in s):
        flg = 1
print(ans)

### FIXED CODE ###

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

import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
u = np.array(uvab[::4], np.int64)
v = np.array(uvab[1::4], np.int64)
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = csr_matrix((a, (u, v)), shape=(n + 1, n + 1))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n + 1, n + 1))

yen = dijkstra(yen_matrix, directed=False, indices=s)[1:]
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)[1:]

costs = (yen + snuuk).astype(int)
costs = sorted(zip(range(1, n + 1), costs.tolist()), key=itemgetter(1), reverse=True)

money = 10 ** 15
city, cost = costs.pop()
for i in range(n):
    if city <= i:
        while True:
            city, cost = costs.pop()
            if city > i:
                break
    print(money - cost)


### FIXED CODE ###

import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))
### BUGGY CODE ###

n,k = map(int, input().split())
l = list(map(int, input().split()))
s = 0
l2 = [0 for _ in range(k)]
for i in range(n-k+1):
  if s < sum(l[i:i+k]):
    s = sum(l[i:i+k])
    for j in range(k):
      l2[j] = i + j
ans = 0
for i in range(k):
  ans += (1+l[l2[i]])/2
print("{:.8}".format(ans))

### FIXED CODE ###

n,k = map(int, input().split())
l = list(map(int, input().split()))
l2 = [0 for _ in range(n+1)]
for i in range(n):
  l[i] = 1+l[i]
for i in range(n):
  l2[i + 1] = l2[i]+l[i]
l3 = []
for i in range(n-k+1):
  l3.append(l2[i+k]-l2[i])
print("{:.8}".format(max(l3)/2))
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

k = 0
score_list = []
for i in range(N):
  start_position = i
  position = i
  score = 0
  for k in range(K):
    position = P[position] - 1
    score += C[position]
    score_list.append(score)

    if start_position == position:
      if score < 0:
        break
        
print(max(score_list))



### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [p - 1 for p in P]
C = list(map(int, input().split()))

vis = [False] * N
ans = [-float("inf")] * N

for root in range(N):
  if vis[root]:
    continue
  vis[root] = True
  
  cycle = [root]
  costs = [C[root]]
  u = P[root]
  vis[u] = True
  
  while u != root:
    cycle.append(u)
    costs.append(C[u])
    u = P[u]
    vis[u] = True

  L = len(cycle)
  S = sum(costs)
  for i, v in enumerate(cycle):
    cnt = 0
    for step in range(1, min(L, K) + 1):
      cnt += costs[(i + step) % L]
      val1 = cnt
      val2 = cnt + (K - step) // L * S
      ans[v] = max(ans[v], val1, val2)

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

def get_ints():
  return list(map(int,input().split()))

n = int(input())
a = get_ints()
b = get_ints()

cnt = [0]*(n+1)
for x in a+b:
  cnt[x] += 1

q = [set() for i in range(n+1)]
for i in range(1,n+1):
  if cnt[i] > n:
    print('No')
    exit(0)
  q[cnt[i]].add(i)
print('Yes')

list_a = [[] for i in range(n+1)]
cnt_a = {}
for i in range(n):
  list_a[a[i]].append(i)
  if a[i] not in cnt_a:
    cnt_a[a[i]] = 1
  else:
    cnt_a[a[i]] += 1

list_b = [[] for i in range(n+1)]
cnt_b = {}
for i in range(n):
  list_b[b[i]].append(i)
  if b[i] not in cnt_b:
    cnt_b[b[i]] = 1
  else:
    cnt_b[b[i]] += 1

def get_any(cnt_, x):
  for key in cnt_.keys():
    if key != x:
      return key
  assert False

ans = [-1]*n

for i in range(n,0,-1):
  s = list(q[i])
  x,y = 0,0
  if len(s) == 0:
    x = get_any(cnt_a, -1)
    y = get_any(cnt_b, x)
  elif len(s) == 1:
    x = s[0]
    if len(list_a[x]) == 0: # b kara
      y = x
      x = get_any(cnt_a, y)
    else: # a kara
      y = get_any(cnt_b, x)
  else: # 2
    x,y = s
    if len(list_a[x]) == 0:
      x,y = y,x

  ans[list_a[x].pop()] = y
  list_b[y].pop()
  def update_cnt(cnt_, x):
    cnt_[x] -= 1
    if cnt_[x] == 0:
      del cnt_[x]
  def use(x):
    q[cnt[x]].remove(x)
    cnt[x] -= 1
    q[cnt[x]].add(x)
  update_cnt(cnt_a, x)
  update_cnt(cnt_b, y)
  use(x)
  use(y)

print(' '.join(map(str,ans)))

### FIXED CODE ###

def get_ints():
  return list(map(int,input().split()))

n = int(input())
a = get_ints()
b = get_ints()

cnt = [0]*(n+1)
for x in a+b:
  cnt[x] += 1

q = [set() for i in range(n+1)]
for i in range(1,n+1):
  if cnt[i] > n:
    print('No')
    exit(0)
  q[cnt[i]].add(i)
print('Yes')

def make_cnt(a):
  cnt_ = {}
  for i in range(n):
    if a[i] not in cnt_:
      cnt_[a[i]] = [i]
    else:
      cnt_[a[i]].append(i)
  return cnt_

cnt_a = make_cnt(a)
cnt_b = make_cnt(b)

def get_any(cnt_, x):
  for key in cnt_.keys():
    if key != x:
      return key
  assert False

ans = [-1]*n

for i in range(n,0,-1):
  s = list(q[i])
  x,y = 0,0
  if len(s) == 0:
    x = get_any(cnt_a, -1)
    y = get_any(cnt_b, x)
  elif len(s) == 1:
    x = s[0]
    if x not in cnt_a: # b kara
      y = x
      x = get_any(cnt_a, y)
    else: # a kara
      y = get_any(cnt_b, x)
  else: # 2
    x,y = s
    if x not in cnt_a:
      x,y = y,x

  ans[cnt_a[x][-1]] = y
  def update_cnt(cnt_, x):
    cnt_[x].pop()
    if len(cnt_[x]) == 0:
      del cnt_[x]
  def use(x):
    q[cnt[x]].remove(x)
    cnt[x] -= 1
    q[cnt[x]].add(x)
  update_cnt(cnt_a, x)
  update_cnt(cnt_b, y)
  use(x)
  use(y)

print(' '.join(map(str,ans)))
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC78 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,z,w = LI()
a = LI()
que = deque(a)
tmp1 = que.popleft()
tmp2 = w
turn = 0
while que:
    if turn == 0:
        if tmp1 <= que[0]:
            tmp1 = que.popleft()
        else:
            turn = 1
    else:
        if tmp2 >= que[0]:
            tmp2 = que.popleft()
        else:
            turn = 0
print(abs(tmp1-tmp2))


### FIXED CODE ###

#!/usr/bin/env python3
#ABC78 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,z,w = LI()
a = LI()
if n == 1:
    print(abs(a[-1] - w))
else:
    print(max(abs(a[-1]-w),abs(a[-2]-a[-1])))
### BUGGY CODE ###

from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

ans_dict = {}
value_dict = {1: 0}
for i in range(n):
    num = a_list[i]
    if num in ans_dict.keys():
        print(ans_dict[num])
    else:
        buff = a_list[:i]
        buff.extend(a_list[i+1:])
        c = Counter(buff)

        tmp_ans = 0
        for value in c.values():
            if value in value_dict.keys():
                tmp_ans += value_dict[value]
            else:
                tmp = int((value * (value - 1))/2)
                tmp_ans += tmp
                value_dict[value] = tmp
        ans_dict[num] = tmp_ans
        print(tmp_ans)



### FIXED CODE ###

from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)
### BUGGY CODE ###

n,t=map(int,input().split())
a=list(map(int,input().split()))
saisyo=min(a)
saidai=0
count=0

for i in range(n-1):
    x=a.pop()
    if x==saisyo:
        saisyo=min(a)
    elif x-saisyo>=saidai:
        mouke=x-saisyo
        if mouke>saidai:
            saidai=mouke
            count=1
        elif mouke==saidai:
            count+=1
    
print(count)

### FIXED CODE ###

n,t=map(int,input().split())
a=list(map(int,input().split()))
saisyo=a[0]
saidai=0
count=0
for i in range(n):
    if a[i]<saisyo:saisyo=a[i]
    else:
        if a[i]-saisyo>saidai:
            saidai=a[i]-saisyo
            count=1
        elif a[i]-saisyo==saidai:
            count+=1
print(count)
### BUGGY CODE ###

import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")




### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    b = [0 for i in range(n)]
    ans = []

    for i in range(n // 2, n):
        if a[i] == 1:
            b[i] = a[i]
            ans.append(i + 1)

    for i in range(n // 2 - 1, -1, -1):
        cnt = 0
        for j in range(i * 2 + 1, n, i + 1):
            cnt ^= b[j]
        if cnt != a[i]:
            b[i] = 1
            ans.append(i + 1)

    tmp = len(ans)
    print(tmp)
    if tmp > 0:
        print(*ans, sep=" ")


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

r,g,b,n = map(int,input().split())
ans = 0
x=n//r+1
y=n//g+1
for i in range(x):
    for j in range(y):
        if r*i+g*j > n:
            break
        if (n-r*i-g*j)%b == 0:
            ans+=1
print(ans)

### FIXED CODE ###

r,g,b,n = map(int,input().split())
ans = 0
x=n//r+1
y=n//g+1
for i in range(x):
    for j in range(y):
        if r*i+g*j > n:
            break
        if (n-r*i-g*j)%b == 0:
            ans+=1
print(ans)
### BUGGY CODE ###


N,K = map(int,input().split())

now = 0
lis = []

for i in range(N):

    a,b = map(int,input().split())
    lis += [a]*b



lis.sort()
print (lis[K-1])


### FIXED CODE ###


N,K = map(int,input().split())

now = 0
dic = {}
lis = []

for i in range(N):

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

    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
        lis.append(a)

lis.sort()

for i in lis:

    now += dic[i]

    if now >= K:
        print (i)
        break
### BUGGY CODE ###

N,W=map(int,input().split())
wl=[]
vl=[]
for i in range(N):
  w,v=map(int,input().split())
  wl.append(w)
  vl.append(v)

dp=[[-float("inf") for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
  dp[0][i]=0

for n in range(1,N+1):
  for w in range(1,W+1):
    if wl[n-1]<=w:
      dp[n][w]=max(dp[n-1][w-wl[n-1]]+vl[n-1],dp[n-1][w])
    else:
      dp[n][w]=dp[n-1][w]

print(str(dp[N][W]))

### FIXED CODE ###

N,W=map(int,input().split())
wl=[]
vl=[]
for i in range(N):
  w,v=map(int,input().split())
  wl.append(w)
  vl.append(v)

dp=[[-float("inf") for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
  dp[0][i]=0

for n in range(1,N+1):
  for w in range(1,W+1):
    if wl[n-1]<=w:
      dp[n][w]=max(dp[n-1][w-wl[n-1]]+vl[n-1],dp[n-1][w])
    else:
      dp[n][w]=dp[n-1][w]

print(str(dp[N][W]))
### BUGGY CODE ###

n = int(input())
s = input()
# st = set()
# for i in range(n-2):
#     for j in range(i+1, n-1):
#         for k in range(j+1, n):
#             pin = s[i] + s[j] + s[k]
#             st.add(pin)
# print(st)
count = 0
for i in range(1000):
    if len(str(i)) == 1:
        v = "00" + str(i)
    elif len(str(i)) == 2:
        v = "0" + str(i)
    else:
        v = str(i)
    k = 0
    for j in range(len(v)):
        while k < len(s):
            if s[k] == v[j]:
                k += 1
                break
            k += 1
        else:
            break
    else:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
s = input()
# st = set()
# for i in range(n-2):
#     for j in range(i+1, n-1):
#         for k in range(j+1, n):
#             pin = s[i] + s[j] + s[k]
#             st.add(pin)
# print(st)
count = 0
# for i in range(1000):
#     if len(str(i)) == 1:
#         v = "00" + str(i)
#     elif len(str(i)) == 2:
#         v = "0" + str(i)
#     else:
#         v = str(i)
#     k = 0
#     for j in range(len(v)):
#         while k < len(s):
#             if s[k] == v[j]:
#                 k += 1
#                 break
#             k += 1
#         else:
#             break
#     else:
#         count += 1
for i in range(1000):
    v = [i // 100, (i // 10) % 10, i % 10]
    first = s[:-2].find(str(v[0]))
    if first == -1:
        continue
    second = s[first + 1:-1].find(str(v[1]))
    if second == -1:
        continue
    third = s[first + 1 + second + 1:].find(str(v[2]))
    if third == -1:
        continue
    # print(v, first, second, third, first + second +1)
    count += 1
print(count)
### BUGGY CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
memo = [[None] * (M + 1) for _ in range(N + 1)]
for i in range(1, len(A)):
    A[i] += A[i - 1]
for i in range(1, len(B)):
    B[i] += B[i - 1]
A.insert(0, 0)
B.insert(0, 0)
r = 0
for i, a in enumerate(A):
    for j, b in enumerate(B):
        k = K - a - b
        if k < 0:
            break
        r = max(r, i + j)
print(r)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, len(A)):
    A[i] += A[i - 1]
for i in range(1, len(B)):
    B[i] += B[i - 1]
A.insert(0, 0)
B.insert(0, 0)
r = 0
for i, a in enumerate(A):
    min_idx = 0
    max_idx = len(B) - 1
    while min_idx < max_idx:
        j = (min_idx + max_idx + 1) // 2
        k = K - A[i] - B[j]
        if k < 0:
            max_idx = j - 1
        else:
            min_idx = j
    j = min_idx
    while j + 1 < len(B) and K - A[i] - B[j + 1] >= 0:
        j += 1
    if K - A[i] - B[j] >= 0:
        r = max(r, i + j)
print(r)
### BUGGY CODE ###

from collections import Counter
from itertools import product
N = int(input())
S = input()
Left = Counter()
Right = Counter()
S_left = S[:N]
S_right = S[2*N-1:N-1:-1]
for B in product(range(2),repeat = N):
    red_left = ''
    blue_left = ''
    red_right = ''
    blue_right = ''
    for i in range(N):
        if int(B[i]):
            red_left += S_left[i]
            red_right += S_right[i]
        else:
            blue_left += S_left[i]
            blue_right += S_right[i]
    Left[red_left + '|' + blue_left] += 1
    Right[blue_right + '|' + red_right] += 1
ans = 0
for i in Left.keys():
    ans += Left[i]*Right[i]
print(ans)

### FIXED CODE ###

from collections import Counter
from itertools import product
N = int(input())
S = input()
Left = Counter()
Right = Counter()
S_left = S[:N]
S_right = S[2*N-1:N-1:-1]
for B in product(range(2),repeat = N):
    red_left = ''
    blue_left = ''
    red_right = ''
    blue_right = ''
    for i in range(N):
        if B[i]:
            red_left += S_left[i]
            red_right += S_right[i]
        else:
            blue_left += S_left[i]
            blue_right += S_right[i]
    Left[red_left + '|' + blue_left] += 1
    Right[blue_right + '|' + red_right] += 1
ans = 0
for i in Left.keys():
    ans += Left[i]*Right[i]
print(ans)
### BUGGY CODE ###

n=int(input())
A=[int(i) for i in input().split()]
b=[A[i] - (i+1) for i in range(n)]
c=[A[i] + (i+1) for i in range(n)]
ans=0
for i in range(n):
    ans += (c[i+1:].count(-c[i]))
    ans += (b[i+1:].count(-c[i]))
print(ans)

### FIXED CODE ###

from collections import defaultdict
n=int(input())
A=[int(i) for i in input().split()]
d=defaultdict(int)

b=[A[i] - (i+1) for i in range(n)]
c=[A[i] + (i+1) for i in range(n)]

l=[]
ans=0
d=defaultdict(int)
for i in range(1,n)[::-1]:
    d[c[i]]+=1
    d[b[i]]+=1
    ans+= d[-c[i-1]]
print(ans)
### BUGGY CODE ###

import bisect
N = int(input())

arr = [int(input())]
for _ in range(N-1):
    a = int(input())
    x = bisect.bisect_left(arr, a)
    if x == 0:
        bisect.insort_left(arr, a)
    else:
        arr[x-1] = a


print(len(arr))


### FIXED CODE ###

import bisect
from collections import deque
N = int(input())

arr = deque([int(input())])
for _ in range(N-1):
    a = int(input())
    x = bisect.bisect_left(arr, a)
    if x == 0:
        arr.appendleft(a)
    else:
        arr[x-1] = a


print(len(arr))
### BUGGY CODE ###

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

def comb(n, r):
    return math.factorial(n) // math.factorial(n - r)

maxi = 0
i = n-1
key = a[i] // 2
ok = n
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if key <= a[mid]: ok = mid
    else: ng = mid
if ok < i: 
    if comb(a[i], a[ok]) > maxi:
        maxi = comb(a[i], a[ok])
        ans = [a[i], a[ok]]
if ng >= 0: 
    if comb(a[i], a[ng]) > maxi:
        maxi = comb(a[i], a[ng])
        ans = [a[i], a[ng]]
print("{} {}". format(ans[0], ans[1]))

### FIXED CODE ###

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

def comb(n, r):
    return math.factorial(n) // math.factorial(n - r)

maxi = 0
i = -1
key = a[i] // 2
for j in range(n):
    if a[j] > key:
        break
# print(j, n-1)
# print(j, key, a)
if abs(a[j-1] - key) >= abs(a[j] - key) and j < n-1:
    ans = [a[i], a[j]]
else:
    ans = [a[i], a[j-1]]
# ok = n
# ng = -1
# while abs(ok - ng) > 1:
#     mid = (ok + ng) // 2
#     if key <= a[mid]: ok = mid
#     else: ng = mid
# if ok < i: 
#     if comb(a[i], a[ok]) > maxi:
#         maxi = comb(a[i], a[ok])
#         ans = [a[i], a[ok]]
# if ng >= 0: 
#     if comb(a[i], a[ng]) > maxi:
#         maxi = comb(a[i], a[ng])
#         ans = [a[i], a[ng]]
print("{} {}". format(ans[0], ans[1]))
### BUGGY CODE ###

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

if 0 in A:
  print(0)
else:
  ans = 1
  for i in range(N):
    ans *= A[i]
  if ans > 10**18:
    print(-1)
  else:
    print(ans)

### FIXED CODE ###

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)
### BUGGY CODE ###

N = int(input())

word = []
for i in range(N):
    a = int(input())
    if a in word:
        word.remove(a)
    else:
        word.append(a)
        
print(len(word))

### FIXED CODE ###

N = int(input())

word = set()
for i in range(N):
    a = int(input())
    if a in word:
        word.remove(a)
    else:
        word.add(a)
        
print(len(word))
### BUGGY CODE ###

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

for i in range(0, len(A)):
    B = A[:i] + A[i+1:]
    ans = 0
    for e in set(B):
        l = B.count(e)
        ans += l * (l-1) // 2
    print(ans)


### FIXED CODE ###

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

counts = {}
for e in A:
    if e not in counts:
        counts[e] = 0
    counts[e] += 1

ans = 0
for e in counts:
    ans += counts[e] * (counts[e]-1) // 2

for i in range(0, len(A)):
    print(ans - counts[A[i]] + 1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

BC = []
for i in range(Q):
    B, C = map(int, input().split())
    D = [C if l == B else l for l in A]
    print(sum(D))
    A = D

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

A_list = [0]*10**5
for i in A:
    A_list[i - 1]+=1

goukei = sum(A)

for i in range(Q):
    B, C = map(int, input().split())
    goukei = goukei + A_list[B - 1] * (C - B)
    print(goukei)
    A_list[C - 1] += A_list[B - 1]
    A_list[B - 1] = 0
### BUGGY CODE ###

import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b=map(int,input().split())
ans=1
while ans*8//100!=a or ans//10!=b:
    ans+=1
print(ans)

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

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

for i in range(100000):
    tmp=int(i*0.08)
    tmp2=int(i*0.1)
    if a==tmp and b==tmp2:
        print(i)
        break
else:
    print(-1)
### BUGGY CODE ###

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

### FIXED CODE ###

a, b, c, d = map(int, input().split())

def gcd(c, d):
    while d:
        c, d = d, c % d
    return c

lcm = c * d // gcd(c, d)
b_num = b - (b // c) - (b // d) + (b // lcm)
a_num = a - 1 - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm)
print(int(b_num - a_num))