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

N=int(input())
S=list(input())
a=[0]*4

for i in range(N):
  if S[i]=='R':a[0]+=1
  if S[i]=='G':a[1]+=1
  if S[i]=='B':a[2]+=1
    
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and j-i==k-j:
        a[3]+=1

print(a[0]*a[1]*a[2]-a[3])

### FIXED CODE ###

N=int(input())
S=list(input())
a=[0]*4

for i in range(N):
  if S[i]=='R':a[0]+=1
  if S[i]=='G':a[1]+=1
  if S[i]=='B':a[2]+=1
    
for i in range(N):
  for j in range(i+1,N):
    k=j+(j-i)
    if k>=N:
      break
    else:
      if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and j-i==k-j:
        a[3]+=1

print(a[0]*a[1]*a[2]-a[3])
### BUGGY CODE ###

H,W = (int(x) for x in input().split())

S_arr_arr = [[1]*(W+2)]
for i in range(H):
    S_arr_arr.append([0 if s=="." else 1 for s in "#"+input()+"#"])
S_arr_arr.append([1]*(W+2))

W_arr_arr = [[0]*(W+2) for _ in range(H+2)]
for j in range(H+2):
    i_begin = 0
    for i in range(W+2):
        if S_arr_arr[j][i] == 1:
            for ix in range(i_begin+1, i):
                W_arr_arr[j][ix] += i-i_begin-1
            i_begin = i
for i in range(W+2):
    j_begin = 0
    for j in range(H+2):
        if S_arr_arr[j][i] == 1:
            for jx in range(j_begin+1, j):
                W_arr_arr[jx][i] += j-j_begin-1
            j_begin = j

max_ans = max([max(W_arr) for W_arr in W_arr_arr]) - 1

print(max_ans)


### FIXED CODE ###

H,W = (int(x) for x in input().split())

S_arr_arr = [[1]*(W+2)]
for i in range(H):
    S_arr_arr.append([0 if s=="." else 1 for s in "#"+input()+"#"])
S_arr_arr.append([1]*(W+2))

W_arr_arr = [[0]*(W+2) for _ in range(H+2)]
for j in range(H+2):
    i_begin = 0
    for i in range(W+2):
        if S_arr_arr[j][i] == 1:
            for ix in range(i_begin+1, i):
                W_arr_arr[j][ix] += i-i_begin-1
            i_begin = i
for i in range(W+2):
    j_begin = 0
    for j in range(H+2):
        if S_arr_arr[j][i] == 1:
            for jx in range(j_begin+1, j):
                W_arr_arr[jx][i] += j-j_begin-1
            j_begin = j

max_ans = max([max(W_arr) for W_arr in W_arr_arr]) - 1

print(max_ans)
### BUGGY CODE ###

H, W, M = map(int, input().split())

Hc = [0 for i in range(H)]
Wc = [0 for i in range(W)]
HW = [[0 for i in range(W)] for i in range(H)]

for m in range(M):
  h, w = map(int, input().split())
  Hc[h - 1] += 1
  Wc[w - 1] += 1
  HW[h - 1][w - 1] = 1
Hcmax = max(Hc)
Hcmax_idx = [i for i, x in enumerate(Hc) if x == Hcmax] 
Wcmax = max(Wc)
Wcmax_idx = [i for i, x in enumerate(Wc) if x == Wcmax] 

ans = Hcmax + Wcmax - 1
f = False
for i in Hcmax_idx:
  for j in Wcmax_idx:
    if HW[i][j] == 0:
      ans = Hcmax + Wcmax
      f = True
      break
  if f:
    break
print(ans)

### FIXED CODE ###

H, W, M = map(int, input().split())

Hc = [0 for i in range(H)]
Wc = [0 for i in range(W)]
B = []

for m in range(M):
  h, w = map(int, input().split())
  Hc[h - 1] += 1
  Wc[w - 1] += 1
  B.append((h - 1, w - 1))
Hcmax = max(Hc)
Hcmax_idx = [i for i, x in enumerate(Hc) if x == Hcmax] 
Wcmax = max(Wc)
Wcmax_idx = [i for i, x in enumerate(Wc) if x == Wcmax] 

ans = Hcmax + Wcmax - 1
B = set(B)
f = False
for i in Hcmax_idx:
  if f:
    break
  for j in Wcmax_idx:
    if (i, j) not in B:
      ans = Hcmax + Wcmax
      f = True
      break
print(ans)
### BUGGY CODE ###

# RGBの数列からから'R,G,B'を取り出す必要がある．
# RGBの組み合わせのなかから(r*g*b)の中から，例えば，Rを固定して，Rからの距離の絶対値が一致するようなものは
# iを固定して， j-i=k-j= l として j,kの位置で，i以外の２文字になっているかを確認する．
# i
from collections import deque
N=int(input())
S=input()
R=deque()
G=deque()
B=deque()
for i,s in enumerate(S):
    if s=='R':
        R.append(i)
    if s == 'G':
        G.append(i)
    if s == 'B':
        B.append(i)

rgb = len(R)*len(G)*len(B)
for i in range(0,N):
    if i in R:
        lest1 = G
        lest2 = B
    elif i in G:
        lest1 = B
        lest2 = R
    else:
        lest1 = R
        lest2 = G
    max_j_width = int((N-1-i)/2)+1
    for j in range(1,max_j_width+1):
        if i+j in lest1 and i+2*j in lest2:
            rgb-=1
        if i+2*j in lest1 and i+j in lest2:
            rgb-=1
print(rgb)









### FIXED CODE ###

# RGBの数列からから'R,G,B'を取り出す必要がある．
# RGBの組み合わせのなかから(r*g*b)の中から，例えば，Rを固定して，Rからの距離の絶対値が一致するようなものは
# iを固定して， j-i=k-j= l として j,kの位置で，i以外の２文字になっているかを確認する．
# i
from collections import deque
N=int(input())
S=input()
R=deque()
G=deque()
B=deque()
for i,s in enumerate(S):
    if s=='R':
        R.append(i)
    if s == 'G':
        G.append(i)
    if s == 'B':
        B.append(i)

rgb = len(R)*len(G)*len(B)
import bisect
# ワンホット表現にしてみる
R_one = [0 for _ in range(N+3)]
G_one = [0 for _ in range(N+3)]
B_one = [0 for _ in range(N+3)]

for r in R:
    R_one[r] = 1
for g in G:
    G_one[g] = 1
for b in B:
    B_one[b] = 1

for i in range(0,N):
    if i in R:
        lest1 = G_one
        lest2 = B_one
    elif i in G:
        lest1 = B_one
        lest2 = R_one
    else:
        lest1 = R_one
        lest2 = G_one
    max_j_width = int((N-1-i)/2)+1
    for j in range(1,max_j_width+1):
        if lest1[i+j]== lest2[i+2*j] == 1:
            rgb-=1
        elif lest2[i + j] == lest1[i + 2 * j] == 1:
            rgb-=1
print(rgb)
### BUGGY CODE ###

n = int(input())
s = []
ans = 0
for i in range(n):
    prize = input()
    if prize in s:
        continue
    else:
        s.append(prize)
        ans += 1
print(len(s))

### FIXED CODE ###

n = int(input())
s = set()
for i in range(n):
    s.add(input())
print(len(s))
### BUGGY CODE ###

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s=s0()
n=n0()
q=s2(n)

for a in q:
    if a[0]=="1":
        s=s[::-1]
    else:
        b=a.split()
        if b[1]=="1":
            s="{}{}".format(b[2],s)
        else:
            s="{}{}".format(s,b[2])
print(s)

### FIXED CODE ###

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

from collections import deque 
s=s0()
n=n0()
q=s2(n)

d1=deque()
d2=deque()

f=False
for a in q:
    if a[0]=="1":
        f=not(f)
    else:
        if a[2]=="1":
            if f==False:
                d1.appendleft(a[4])
            else:
                d2.append(a[4])                
        else:
            if f==False:
                d2.append(a[4])
            else:
                d1.appendleft(a[4])
ss=''.join(list(d1))+s+''.join(list(d2))
print(ss[::-1] if f else ss)
### BUGGY CODE ###

from sys import stdin
#n = int(stdin.readline().rstrip())
#li = list(int(stdin.readline().rstrip()) for _ in range(n))
n = int(input())
li = [int(input()) for _ in range(n)]
li_to = sorted(li)
one = li_to[-1]
two = li_to[-2]
for i in range(n):
    if max(li) != li[i]:
        print(one)
    else:
        print(two)

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
a_m = max(a)
a_i = a.index(a_m)
a.sort()
for i in range(len(a)):
  if i == a_i:
    print(a[-2])
  else:
    print(a_m)
### BUGGY CODE ###

n = int(input())
L = [int(i) for i in input().split()]

count=0
for i in range(0, len(L),1):
  for j in range(i+1,len(L),1):
    for k in range(j+1,len(L),1):
      if (L[i] + L[j] > L[k]) & (L[i] + L[k] > L[j]) & (L[j] + L[k] > L[i]):
        count +=1
print(count)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += bisect_left(L, L[i]+L[j])-j-1
print(ans)
### BUGGY CODE ###

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


def eq(s, b, n, i, j):
  return s[i][(j + b) % n] != s[j][(i + b) % n]

def yoi2(s, b):
  for i in range(n):
    for j in range(i):
      if eq(s, b, n, i, j):
        return 0
  return 1

sol = n * sum(yoi2(s, b) for b in range(n))
print(sol)

### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)
### BUGGY CODE ###

import functools
import operator
import itertools
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

p = [functools.reduce(operator.add, x) for x in itertools.product(A, B, C)]
p.sort(reverse=True)
for x in p[:min(3000, K)]:
    print(x)

### FIXED CODE ###

from collections import defaultdict

def append(m, printed, cand_a, cand_b, cand_c):
    key = "{}-{}-{}".format(cand_a, cand_b, cand_c)
    key2 = "{}-{}-{}".format(cand_a-1, cand_b, cand_c)
    key3 = "{}-{}-{}".format(cand_a, cand_b-1, cand_c)
    key4 = "{}-{}-{}".format(cand_a, cand_b, cand_c-1)
    if not key in printed \
            and cand_a < len(A) \
            and cand_b < len(B) \
            and cand_c < len(C) \
            and not key in m \
            and not key2 in m \
            and not key3 in m \
            and not key4 in m :
#       print("Appended {}".format(key))
        m[key] = A[cand_a] + B[cand_b] + C[cand_c]
    return m

X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

a = 0
b = 0
c = 0

n_print = 0
#print(A, B, C)
memo = {}
printed = defaultdict(lambda: False)
while True:
    summ = A[a] + B[b] + C[c]
    printed["{}-{}-{}".format(a, b, c)] = True

    print(summ)

#   print(memo.items())
#   print(a, b, c)
#   print("")

    n_print += 1
    if n_print == K:
        break

    memo = append(memo, printed, a+1, b, c)
    memo = append(memo, printed, a, b+1, c)
    memo = append(memo, printed, a, b, c+1)

    max_k = max(memo, key=memo.get)
    a, b, c = max_k.split("-")
    a = int(a)
    b = int(b)
    c = int(c)
        
    memo.pop(max_k)
#   print("Pop {}".format(max_k))
### BUGGY CODE ###

a=input()
s=''
for item in a :
  if item=='?' :
    s+='D'
  else :
    s+=item
print(s)

### FIXED CODE ###

a=input()
a=a.replace('?','D')
print(a)
### BUGGY CODE ###


def check_alloc(weights, cnt, cpct):	
	num = 1
	cur = 0
	for i in range(len(weights)):
		w = weights[i]
		if cur + w > cpct:
			cur = w
			num += 1
			if num > cnt or cur > cpct:
				return False
		else:
			cur += w
	return True

n, k = map(int, input().split())
weights = [0] * n
cpct = 0
for i in range(n):
	weight = int(input())
	weights[i] = weight
	cpct += weight

cpct = int(cpct/k)
while True:	
	can_alloc = check_alloc(weights, k, cpct)
	if can_alloc == False:
		cpct += 1
	else:
		break

print(cpct)



### FIXED CODE ###

import sys

def check_alloc(weights, k, cpct):
	num = 1
	cur = 0
	for i in range(len(weights)):
		w = weights[i]
		if cur + w > cpct:
			cur = w
			num += 1
			if num > k or cur > cpct:
				return False
		else:
			cur += w
	return True

n, k = map(int, input().split())
weights = [0] * n
sum = 0
maxi = 0
for i in range(n):
	w = int(input())
	weights[i] = w
	sum += w
	maxi = max(maxi, w)

if k == 1:
	print(sum)
	sys.exit()

start = maxi
end = sum
cpct = 0
while start <= end:
	cpct = int(start + (end - start) / 2)
	check = check_alloc(weights, k, cpct)
	if check == False:
		start = cpct + 1
	else:
		if start == end: break
		end = cpct
	
print(cpct)
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
A.sort()
M=10**6+1
cnt=[True]*M
dep=[x for x in set(A) if A.count(x) >= 2]
for i in A:
    if cnt[i]==False:
        continue
    for j in range(2*i,M,i):
        #print(i,M,j)
        cnt[j]=False
ans=0
for i in set(A):
    if cnt[i] and i not in dep:
        ans+=1
print(ans)


### FIXED CODE ###

from collections import Counter
max_=10**6+1
ans=0

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

b=[True]*(max_+1)
data.sort()
c=Counter(data)
#print(c)

for d in data:
    if b[d]:
        for j in range(d,max_,d):
            b[j]=False
        if c[d]==1:#複数存在考慮
            ans+=1
print(ans)
### BUGGY CODE ###

N,Y = map(int,input().split(" "))
a = 0
flag = 0
while a <= N:
  b = 0
  while b <= N:
    c = N-a-b
    if 10000*a+5000*b+1000*c == Y and c >= 0:
      print(a,b,c)
      flag = 1
      break
    if flag == 1:
      break
    b+=1
  if flag == 1:
    break
  a+=1
if flag == 0:
  print(-1,-1,-1)

### FIXED CODE ###

#C問題
N,Y=map(int,input().split())
flag=0
for x in range(N+1):
    for y in range(N+1):
        if x+y>N:
            pass
        else:
            z=N-(x+y)
            if 10000*x+5000*y+1000*z == Y:
                flag=1
                X,Y,Z=x,y,z
                break
    if flag == 1:
        break
if flag == 0:
    print(-1,-1,-1,)
else:
    print(X,Y,Z)
### BUGGY CODE ###

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0

for i in range(N-2) :
    for j in range(i+1,N-1) :
        left = j-1
        right = N
        while right - left > 1 :
            mid = (left + right) // 2
            if (L[i] < L[j] + L[mid]) and (L[j] < L[i] + L[mid]) and (L[mid] < L[i] + L[j]) :
                left = mid
            else : right = mid
        ans += max(left - j, 0 )

print(ans)

         


### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0

for i in range(N-2) :
    for j in range(i+1,N-1) :
        a = L[i] + L[j]
        X =bisect.bisect_left(L,a)
        ans += X- j - 1
        
    
print(ans)
### BUGGY CODE ###

h, w = map(int, input().split())
s = [input() for _ in range(h)]

d = ((-1, 0), (1, 0), (0, -1), (0, 1))
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        c = 1
        for dy, dx in d:
            y, x = i, j
            while True:
                y += dy
                x += dx
                if not(0 <= y < h) or not(0 <= x < w):
                    break
                if s[y][x] == '#':
                    break
                c += 1
        ans = max(ans, c)
print(ans)

### FIXED CODE ###

import numpy as np

h, w = map(int, input().split())
s = [input() for _ in range(h)]

t = np.zeros((h, w), dtype=np.int32)
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            t[i][j] = 1

l = np.zeros((h, w), dtype=np.int32)
r = np.zeros((h, w), dtype=np.int32)
u = np.zeros((h, w), dtype=np.int32)
d = np.zeros((h, w), dtype=np.int32)

for i in range(w):
    if i == 0:
        l[:, i] = t[:, i]
    else:
        l[:, i] = (l[:, i-1] + 1) * t[:, i]

for i in range(w-1, -1, -1):
    if i == w-1:
        r[:, i] = t[:, i]
    else:
        r[:, i] = (r[:, i+1] + 1) * t[:, i]

for i in range(h):
    if i == 0:
        u[i] = t[i]
    else:
        u[i] = (u[i-1] + 1) * t[i]

for i in range(h-1, -1, -1):
    if i == h-1:
        d[i] = t[i]
    else:
        d[i] = (d[i+1] + 1) * t[i]

lrud = l+r+u+d-3
print(np.max(lrud))
### BUGGY CODE ###

import numpy as np
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c
L = len(C)
A = np.array(C)

ans = 1
f = np.ones(L + 1, dtype="int")
for i in range(2, L):
    ans += np.sum(f[A[:i-1] == A[i]])
    f[i + 1] = ans

print(ans)

### FIXED CODE ###

import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print(ans % (10 ** 9 + 7))
### BUGGY CODE ###

ks = list(map(int, input().split()))
k = min(ks)
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if ks[1] == x + y + z:
                ans += 1
            else:
                pass

print(ans)

### FIXED CODE ###

k, s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >=0 and z <= k:
            ans += 1
        else:
            pass
        

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

n, m = list(map(int, input().split()))
a = []
for _ in range(m):
    a.append(int(input()))
cur = 0
dp = [0 for _ in range(n + 1)]
flags = [0 for _ in range(n + 1)]
for i in range(n + 1):
    if i in a:
        flags[i] = 1
dp[0], dp[1] = 1, 1
if flags[1]:
    dp[1] = 0
for i in range(2, n + 1):
    if flags[i]:
        continue
    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= (10 ** 9 + 7)
print(dp[n])


### FIXED CODE ###

n, m = list(map(int, input().split()))
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
dp = [0 for _ in range(n+1)]
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2, n+1):
    if not(i in a):
        dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % 1000000007)
### BUGGY CODE ###

#!/usr/bin/python3

import sys
import bisect
from collections import defaultdict

sys.setrecursionlimit(1000000)

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

nbs = defaultdict(list)

for i in range(n - 1):
    (u, v) = map(int, input().split())
    nbs[u - 1].append(v - 1)
    nbs[v - 1].append(u - 1)


mlen =  [ 0 ] * n
dp = [ float('inf') ] * n

def getmlen(cur, p, ctail):
    oidx = 0
    ov = 0
    
    idx = bisect.bisect_left(dp, a[cur])
    ov = dp[idx]

    ntail = ctail
    if ctail < idx:
        ntail = idx

    dp[idx] = a[cur]
    mlen[cur] = ntail + 1
    
    for ch in nbs[cur]:
        if ch == p:
            continue

        getmlen(ch, cur, ntail)
    dp[idx] = ov



getmlen(0, -1, 0)

for i in range(n):
    print(mlen[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from bisect import bisect_left
 
N = int(input())
a = [int(i) for i in input().split()]
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  u, v = map(int, input().split())
  vec[u - 1].append(v - 1)
  vec[v - 1].append(u - 1)
 
lis = [a[0]]
ret = [0] * N
def dfs(cur, pre) :
  for nex in vec[cur] :
    if nex == pre : continue
    if a[nex] > lis[-1] :
      lis.append(a[nex])
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis.pop()
    else :
      pos = bisect_left(lis, a[nex])
      v = lis[pos]
      lis[pos] = a[nex]
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis[pos] = v
 
dfs(0, -1)
 
ret[0] = 1
for i in range(N) :
  print(ret[i])
### BUGGY CODE ###

s=input()
q=int(input())
is_reverse=False
for i in range(q):
    qi=list(input().split())
    if(qi[0]=="1"):
        is_reverse = not is_reverse
    elif(qi[1]=="1"):
        if(is_reverse):
            s=s+qi[2][::-1]
        else:
            s=qi[2]+s
    else:
        if(is_reverse):
            s=qi[2][::-1]+s
        else:
            s=s+qi[2]

if(is_reverse):
    print(s[::-1])
else:
    print(s)

### FIXED CODE ###

s=input()
q=int(input())
is_reverse=False
pre=[]
post=[]
for i in range(q):
    qi=list(input().split())
    if(len(qi)==1):
        is_reverse = not is_reverse
    elif(qi[1]=="1"):
        if(is_reverse):
            post.append(qi[2])
        else:
            pre.append(qi[2])
    else:
        if(is_reverse):
            pre.append(qi[2])
        else:
            post.append(qi[2])

if(is_reverse):
    print(''.join(post)[::-1] + s[::-1] + ''.join(pre))
else:
    print(''.join(pre)[::-1] + s + ''.join(post))
### BUGGY CODE ###

N, A = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
X = max(x)
X = max(X, A)

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)

### FIXED CODE ###

N, A = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
X = max(x)
X = max(X, A)

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)
### BUGGY CODE ###

s=input().split("T")
x,y=map(int,input().split())
A=[]
B=[]
for i,j in enumerate(s):
    if i%2==0:
        A.append(len(j))
    else:
        B.append(len(j))
T=max([sum(A),sum(B),abs(x),abs(y)])
X=len(A)
Y=len(B)
if abs(x)+abs(y)>sum(A)+sum(B):
    print("No")
    exit()
dpx=[[False for i in range(2*T+1)] for _ in range(X+1)]
dpy=[[False for i in range(2*T+1)] for _ in range(Y+1)]
dpx[0][T]=True
dpy[0][T]=True
for l in range(X):
    for i in range(2*T+1):
        if dpx[l][i]:
            dpx[l+1][i+A[l]]=True
            if l==0:
                continue
            dpx[l+1][i-A[l]]=True
for r in range(Y):
    for i in range(2*T+1):
        if dpy[r][i]:
            dpy[r+1][i-B[r]]=True
            dpy[r+1][i+B[r]]=True
if dpx[X][x+T] and dpy[Y][y+T]:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

st = input().split("T")
x, y = map(int, input().split())
XL = []; YL = []; t = 0
for i in range(len(st)):
    if i % 2 == 0:
        XL.append(len(st[i]))
    else:
        YL.append(len(st[i]))
    t += len(st[i])
if abs(x) + abs(y) > t:
    print("No")
else:
    T = max([abs(x), abs(y), t])
    xx = [[False for j in range(2*T+1)] for i in range(len(XL)+1)]
    yy = [[False for j in range(2*T+1)] for i in range(len(YL)+1)]
    xx[0][T]=True
    yy[0][T]=True
    xx[1][T+XL[0]]=True
    for i in range(2, len(XL)+1):
        for j in range(2*T+1):
            if j-XL[i-1] < 0:
                xx[i][j]=xx[i-1][j+XL[i-1]]
            elif j+XL[i-1] > 2*T:
                xx[i][j]=xx[i-1][j-XL[i-1]]
            else:
                xx[i][j]=xx[i-1][j-XL[i-1]] or xx[i-1][j+XL[i-1]]
    
    for i in range(1,len(YL)+1):
        for j in range(2*T+1):
            if j-YL[i-1] < 0:
                yy[i][j]=yy[i-1][j+YL[i-1]]
            elif j+YL[i-1] > 2*T:
                yy[i][j]=yy[i-1][j-YL[i-1]]
            else:
                yy[i][j]=yy[i-1][j-YL[i-1]] or yy[i-1][j+YL[i-1]]

    if xx[len(XL)][x+T] and yy[len(YL)][y+T]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
#print(N)
#print(A)
ans = 1
for i in A:
  ans = ans * i
if ans <= 10 ** 18:
  print(ans)
else:
  print(-1)

### FIXED CODE ###

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

A = sorted(A, reverse=True)
#print(A)

if A[-1] == 0:
  print(0)
  exit()
  
ans = 1

for i in A:
  ans = ans * i
  if ans > 10 ** 18:
    print(-1)
    exit()

print(ans)