Harryxun/stf_run huggingface dataset:
n,k = map(int,input().split())

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

id_one = lst.index(1)
left_length = len(lst[0:id_one]-1)
right_length = len(lst[id_one:]-1)

counter = 0

if left_length > 0:
    left_length -= k
    counter += 1

while left_length > 0:
    counter += 1
    left_length -= k-1

if right_length > 0:
    counter += 1
    right_length -= k

while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

### FIXED CODE ###

n,k = map(int,input().split())
lst = list(map(int,input().split()))

id = lst.index(1)

left = len(lst[0:id])
right = len(lst[id+1:])
mod = max(left%(k-1),right%(k-1))

total = left + right

counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)
x, n = map(int, input().split())
P = list(map(int, input().split()))

P.sort()
P.append(101)

excluded = P.pop(0)

ans, absolute = None, 101

for i in range(0, 102):
    if i == excluded:
        excluded = P.pop(0)
    else:
        if abs(i - x) < absolute:
            ans = i
            absolute = abs(i - x)
    
print(ans)
        


### FIXED CODE ###

x, n = map(int, input().split())
P = list(map(int, input().split()))

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if P.count(a) == 0:
            print(a)
            exit(0)
N = int(input())

print('Yes' if sum(map(N)) % N == 0 else 'No')


### FIXED CODE ###

N = input()
print("No" if int(N) % sum(map(int, N)) else "Yes")
import numpy as np
N = int(input())
A = list(map(int, input().split()))
if N > len(A):
  print(0)
else:
  tmp = 1
  for i in range(N):
    tmp *= A[i]
  if np.log10(tmp) > 18:
    print(-1)
  else:
    print(tmp)


### FIXED CODE ###

s = input().split()
print(int(s[0]) * int(s[1]))
n, k, q = list(map(int, input().split()))
a = [0] * q
for i in range(q):
  a[i] = int(input())

cur_k = [k] * n

for i in range(q):
  cur_k[a[i] - 1] += 1

for i in cur_k:
  if (i > q):
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

s = input()

if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
S = input()
A = [chr(ord("a")+i) for i in range(26)]

if len(set(S)) < 26:
    for a in A:
        if a not in S:
            print(S+a)
            break
else:
    X = []
    for i in range(25, 0, -1):
        if S[i] > S[i-1]:
            X.sort()
            print(S[:i-1]+X[0])
            break
        else:
            X.append(S[i])
    else:
        print(-1)

### FIXED CODE ###

S = input()
C = [chr(97+i) for i in range(26)]

if len(S) != 26:
    for c in C:
        if c not in S:
            print(S + c)
            break
else:
    S = list(S)
    for i in range(25, -1, -1):
        if S[i:] != sorted(S[i:], reverse=True):
            Z = sorted(list(filter(lambda x: x > S[i], S[i:])))
            print("".join(S[:i]) + Z[0])
            break
    else:
        print(-1)
x = int(input())
for i in range(x // 2 + 1):
    if pow(x - pow(i, 5), 1 / 5).is_integer():
        print(i, int(-pow(x - pow(i, 5), 1 / 5)))
        exit()


### FIXED CODE ###

import numpy as np


def main():
    x = int(input())
    A = np.arange(-120, 120)
    a = A ** 5
    for i, a_1 in enumerate(a):
        for j, a_2 in enumerate(a):
            if a_1 - a_2 == x:
                print(A[i], A[j])
                return


if __name__ == "__main__":
    main()
n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

edges = [[] for _ in range(n)]
for u, v, w in uvw:
    u-=1
    v-=1
    edges[u].append([v, w%2])
    edges[v].append([u, w%2])

res = [[] for _ in range(n)]
def dfs(v, p, c):
    res[v] = c
    for e in edges[v]:
        if e[0] == p: continue
        if e[1]%2==1: dfs(e[0], v, 1-c%2)
        else: dfs(e[0], v, c)

dfs(0, -1, 1)
print('\n'.join(list(map(str, res))))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

edges = [[] for _ in range(n)]
for u, v, w in uvw:
    u-=1
    v-=1
    edges[u].append([v, w%2])
    edges[v].append([u, w%2])

res = [[] for _ in range(n)]
def dfs(v, p, c):
    res[v] = c
    for e in edges[v]:
        if e[0] == p: continue
        if e[1]%2==1: dfs(e[0], v, 1-c%2)
        else: dfs(e[0], v, c)

dfs(0, -1, 1)
print('\n'.join(list(map(str, res))))
import sys
N = int(input())
H = list(map(int,input().split()))
C = 0

if sorted(H) == H:
  print("YES")
  sys.exit()
  
for i in range(0,N-1):
  for j in range(1,N):
    tmp = H.replace(H[i],H[j])
    if tmp == sorted(H):
      print("YES")
      sys.exit()
print("NO")

### FIXED CODE ###

import copy
import sys
N = int(input())
H = list(map(int,input().split()))
C = 0

if sorted(H) == H:
	print("YES")
	sys.exit()

for i in range(0,N-1):
	for j in range(1,N):
		L = copy.copy(H)
		L[i],L[j] = L[j],L[i] 
		if L == sorted(H):
			print("YES")
			sys.exit()
print("NO")
1000000000 1000000000

### FIXED CODE ###

h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
elif h%2==0 or w%2==0:
  print(h*w//2)
else:
  print((h*w+1)//2)
from collections import Counter

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

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(1)[0]
    c2m = c2.most_common(1)[0]
    
    ans1 = n//2-c2m[1]
    if c1m[0] != c2m[0]:
      ans1 += n//2-c1m[1]
      else:
        ans1 += n//2-c1.most_common(2)[1][1]
    
    ans2 += n//2-c1m[1]
    if c1m[0] != c2m[0]:
      ans2 += n//2-c2m[1]
      else:
        ans2 += n//2-c2.most_common(2)[1][1]
    print(min(ans1, ans2))

### FIXED CODE ###

from collections import Counter

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

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(2)
    c2m = c2.most_common(2)
    
    if c1m[0][0] != c2m[0][0]:
        print(n-c1m[0][1]-c2m[0][1])
    else:
        mn = n
        if len(set(c1)) > 1:
            mn = min(mn, n-c1m[1][1]-c2m[0][1])
        if len(set(c2)) > 1:
            mn = min(mn, n-c1m[0][1]-c2m[1][1])
            
        print(mn)
for _ in range(n):
    s += input()+" "
ls = s.split()
counter = 0
res = []
for x in ls:
    if ls.count(x) > counter:
        counter = ls.count(x)
for x in set(ls):
    if ls.count(x) == counter:
        res.append(x)
r = sorted(res)
print("\n".join(r))

### FIXED CODE ###

from collections import Counter
n = int(input())
ls = []
for _ in range(n):
    ls.append(input())
res = []
counter = Counter(ls).most_common()
for x in counter:
    if x[1] == counter[0][1]:
        res.append(x[0])
print("\n".join(sorted(res)))
n=int(input())
l=list(map(int,input().split()))
if 0 in l:
  print(0)
else:
	a=1
	for i in l:
  		a=a*i
	    if a>10**18:
  			print(-1)
            exit()
  	print(a)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
if 0 in l:
  print(0)
else:
  a=1
  for i in l:
    a=a*i
    if a>10**18:
      print(-1)
      exit()
  print(a)
import math

ans = 0
N = int(input())
for i in range(N):
    a = int(input())
    if a == 2:
        ans += 1
    elif a%2 == 0:
        continue
    else:
        if math.pow(2, a-1, a) == 1:
            ans += 1

print(ans)

### FIXED CODE ###

ans = 0
N = int(input())
for i in range(N):
    a = int(input())
    if a == 2:
        ans += 1
    elif a%2 == 0:
        continue
    else:
        if pow(2, a-1, a) == 1:
            ans += 1

print(ans)
a, b = map( str, input().split() )
s = a + b
if s == "HH" | s == "DD" : 
   print( "H" ) 
else : 
   print( "D" ) 

### FIXED CODE ###

s = input()
if s == "H H" or s == "D D" : 
   print( "H" ) 
else : 
   print( "D" )
M = int(input())
A = list(map(int,input().split()))
B = [0]*(M+1)
C = [0]*2
D = [0]*2

for i in range(len(A)):
	B[ A[i] ] += 1 # カウント

for i in range(len(B)):
	# 一個しかなかったら条件を満たさないのでするー
	if B[i] < 2: continue

	# 2個以上あれば長方形にスタック
	C.append(i)

	# 4個以上あれば正方形にスタック
	if B[i] >= 4: D.append(i)
# C を降順でソート
C = sorted(C, reverse=True)

rect = C[0] * C[1]
s = max(D)
square = s * s

print(max(rect,square))

### FIXED CODE ###

M = int(input())
A = list(map(int,input().split()))
B = {}
C = [0]*2
D = [0]*2

for i in range(len(A)):
	a = str(A[i])
	# 存在したらカウントアップ
	if (a in B): B[ str(A[i]) ] += 1 # カウント
	# 存在しなかったら 1 で初期化
	else: B[ str(A[i]) ] = 1 # カウント
	# {"1":2, "2":3, "3":1}

for i in B:
	# 一個しかなかったら条件を満たさないのでスルー
	# i: string, B[i] = count
	if B[i] < 2: continue

	# 2個以上あれば長方形にスタック
	C.append(int(i))

	# 4個以上あれば正方形にスタック
	if B[i] >= 4: D.append(int(i))

# C を降順でソート
C = sorted(C, reverse=True)

rect = C[0] * C[1]
s = max(D)
square = s * s

print(max(rect,square))
def A(w, v, n,V):
    mem=[0 for i in range(V+1)]
    if n == 0 or V == 0:
        return 0
 
    for i in range(n):
        for j in range(V,w[i]-1,-1):
            m=v[i]+ mem[j - w[i]]
          if m>mem[j]:
            mem[j]=m
    return mem[V]
n,V=input().split()
n,V=int(n),int(V)
 
w=[0]*n
v=[0]*n
for i in range(n):
  x,y=input().split()
  w[i],v[i]=int(x),int(y)
 
print(A(w,v,n,V))

### FIXED CODE ###

def A(w, v, n,V):
    mem=[0 for i in range(V+1)]
    if n == 0 or V == 0:
        return 0
 
    for i in range(n):
        for j in range(V,w[i]-1,-1):
            m=v[i]+ mem[j - w[i]]
            if m>mem[j]:
                mem[j]=m
    return mem[V]
n,V=input().split()
n,V=int(n),int(V)
 
w=[0]*n
v=[0]*n
for i in range(n):
  x,y=input().split()
  w[i],v[i]=int(x),int(y)
 
print(A(w,v,n,V))
n=input()
dic = {'A': True, 'C': True, 'G': True, 'T': True}
lens = []

for i in range(0, len(n)):
    length = 0
    s = n[i]

    if s not in dic:
        lens.append(length)
        continue

    length += 1
    for j in range(i+1, len(n)):
        t = n[j]
        if t not in dic:
            lens.append(length)
            continue

        length += 1

print(max(lens))

### FIXED CODE ###

n=input()
dic = {'A': True, 'C': True, 'G': True, 'T': True}
lens = []

for i in range(0, len(n)):
    length = 0
    s = n[i]

    if s not in dic:
        lens.append(length)
        continue

    length += 1
    for j in range(i+1, len(n)):
        t = n[j]
        if t not in dic:
            break

        length += 1

    lens.append(length)
print(max(lens))
def exists(value,n,ms,cs):
    if (len(value) != n):
        return False
    if not all([value[i-1] == c for i,c in zip(ms,cs)]):
        return False
    return True
def unzip(li):
    return list(map(list, zip(*li)))
n,m = [int(e) for e in input().split()]
m = [input().split() for e in range(m)]
ms,cs = unzip(m)
ms = [int(e) for e in ms]
for i in range(1000):
    if exists(str(i),n,ms,cs):
        print(i)
        break
print(-1)

### FIXED CODE ###

n,m = map(int,input().split())
sc = [[i for i in map(int,input().split())] for j in range(m)]
start = 0
goal = 0
if n==1:
  start = 0
  goal = 9
elif n==2:
  start = 10
  goal = 99
elif n==3:
  start = 100
  goal = 999

flag = 1
ans = -1
for num in range(start,goal+1):
  flag = 1
  for i in range(m):
    if str(num)[sc[i][0]-1] != str(sc[i][1]): #両辺ともちゃんとstrで変換
      flag = 0
  if flag == 1:
    ans = num
    break

print(ans)
def get_distance(v):              
    distance = [0] * n
    visited = [0] * n
    visited[v] = 1
    dfs(v, 0, distance, visited)
    return distance


def dfs(v, d, distance, visited):
    distance[v] = d
    for u in adj[v]:
        if not visited[u]:
            visited[u] = 1
            dfs(u, d + 1, distance, visited)


n, u, v = map(int, input().split())

adj = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(i) - 1 for i in input().split()) 
    adj[a].append(b)
    adj[b].append(a)

u_distance = get_distance(u - 1)
v_distance = get_distance(v - 1)

ans = 0
for u, v in zip(u_distance, v_distance):
    if u < v and v - 1 > ans:
        ans = v - 1

print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)


def get_distance(v):              
    distance = [0] * n
    visited = [0] * n
    visited[v] = 1
    dfs(v, 0, distance, visited)
    return distance


def dfs(v, d, distance, visited):
    distance[v] = d
    for u in adj[v]:
        if not visited[u]:
            visited[u] = 1
            dfs(u, d + 1, distance, visited)


n, u, v = map(int, input().split())

adj = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(i) - 1 for i in input().split()) 
    adj[a].append(b)
    adj[b].append(a)

u_distance = get_distance(u - 1)
v_distance = get_distance(v - 1)

ans = 0
for u, v in zip(u_distance, v_distance):
    if u < v and v - 1 > ans:
        ans = v - 1

print(ans)
n,a,b,c=map(int,input().split())
ans=[]
ks = [input() for _ in range(n)]
for i in range(n):
  k = k[0]
  if k=="AB":
    if a==0 and b==0:
      print("No")
      quit()
    else:
      if a>b:
        a -= 1
        b+=1
        ans.append("B")
      else:
        if a == 1 and b == 1 and len(ks) > 1:
          if ks[1] == "AC":
            b-=1
            a+=1
            ans.append("A")
          else:
            a -= 1
            b+=1
            ans.append("B")
      else: 
          b-=1
          a+=1
          ans.append("A")
  if k=="BC":
    if c==0 and b==0:
      print("No")
      quit()
    else:
      if c>b:
        c -= 1
        b+=1
        ans.append("B")
      else:
        if c == 1 and b == 1 and len(ks) > 1:
          if ks[1] == "AC":
            b-=1
            c+=1
            ans.append("C")
          else:
            c -= 1
            b+=1
            ans.append("B")
      else: 
          b-=1
          c+=1
          ans.append("C")
  if k=="AC":
    if a==0 and c==0:
      print("No")
      quit()
    else:
      if a>c:
        a -= 1
        c+=1
        ans.append("C")
      else:
        if a == 1 and c == 1 and len(ks) > 1:
          if ks[1] == "BC":
            a-=1
            c+=1
            ans.append("C")
          else:
            c -= 1
            a+=1
            ans.append("A")
      else: 
          c-=1
          a+=1
          ans.append("A")
  del(ks[0])
print("Yes")
for i in ans:
  print(i)

### FIXED CODE ###

n,a,b,c=map(int,input().split())
ans=[]
ks = [input() for _ in range(n)]
for i in range(n):
  k = ks[0]
  if k=="AB":
    if a==0 and b==0:
      print("No")
      quit()
    else:
      if a>b:
        a -= 1
        b+=1
        ans.append("B")
      else:
        if a == 1 and b == 1 and len(ks) > 1:
          if ks[1] == "AC":
            b-=1
            a+=1
            ans.append("A")
          else:
            a -= 1
            b+=1
            ans.append("B")
        else: 
          b-=1
          a+=1
          ans.append("A")
  if k=="BC":
    if c==0 and b==0:
      print("No")
      quit()
    else:
      if c>b:
        c -= 1
        b+=1
        ans.append("B")
      else:
        if c == 1 and b == 1 and len(ks) > 1:
          if ks[1] == "AC":
            b-=1
            c+=1
            ans.append("C")
          else:
            c -= 1
            b+=1
            ans.append("B")
        else: 
          b-=1
          c+=1
          ans.append("C")
  if k=="AC":
    if a==0 and c==0:
      print("No")
      quit()
    else:
      if a>c:
        a -= 1
        c+=1
        ans.append("C")
      else:
        if a == 1 and c == 1 and len(ks) > 1:
          if ks[1] == "BC":
            a-=1
            c+=1
            ans.append("C")
          else:
            c -= 1
            a+=1
            ans.append("A")
        else: 
          c-=1
          a+=1
          ans.append("A")
  del(ks[0])
print("Yes")
for i in ans:
  print(i)
n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
  m = (mx+mn)//2
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))


### FIXED CODE ###

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

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
    if a[i]%x == 0:
      c -= 1
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
  m = (mx+mn)//2
  if m == 0:
    if check(1):
      ans.append(1)
    break
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))
x = (input().count(1))
print(x)

### FIXED CODE ###

x = (input().count('1'))
print(x)
A,B = map(int, input().split())
count = 0
for i in range(A,B+1):
  k = str(i)
  if k == k.reverse :
    count += 1
print(count)


### FIXED CODE ###

A,B = map(int, input().split())
count = 0
for i in range(A,B+1):
  k = str(i)
  if k[0] == k[4] and k[1] == k[3]:
    count += 1
print(count)
n=int(input())
a=list(map(int,input().split()))
ans=0
r,l=0,0
s,x=0,0
while l<n:
  while s+a[r]==x^a[r]:
    s+=a[r]
    x^=a[r]
    r+=1
  ans+=r-l
  s-=a[l]
  x^=a[l]
  if r==l:r+=1
  l+=1
print(ans)

ans=0
for i in range(1,n+1):
  for j in range(i+1,n+2):
    p=0
    q=0
    for k in range(i,j):
      p+=c[k]
      q^=c[k]
    ans+=p==q
    if p==q:print(i-1,j-1)
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
r,l=0,0
s,x=0,0
while l<n:
  while r<n and s+a[r]==x^a[r]:
    s+=a[r]
    x^=a[r]
    r+=1
  ans+=r-l
  s-=a[l]
  x^=a[l]
  if r==l:r+=1
  l+=1
print(ans)
import numpy as np

anum = {}
ans = 0

N = int(input())
strings = [''.join(sorted(input())) for i in range(N)]

for i in range(N):
    if strings[i] in anum:
        ans += anum[i]
    else:
        anum[strings[i]] = 1

print(ans)


### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
dict = {}
ans = 0

for i in s:
    if i in dict:
        ans += dict[i]
        dict[i] += 1
    else:
        dict[i] = 1

print(ans)
n, m = map(int, input().split(' '))

pena = [0 for i in range(n)]
acc = [0 for i in range(n)]

for i in range(m):
    pp, ss = input().split(' ')
    p = int(pp) - 1

    if acc[p] == 0:
        if ss == 'WA':
            pena[p] += 1
        else:
            acc[p] = 1

for i in range(m):
    pena[i] = pena[i] * acc[i]

print(sum(acc), sum(pena))

### FIXED CODE ###

n, m = map(int, input().split(' '))

pena = [0 for i in range(n)]
acc = [0 for i in range(n)]

for i in range(m):
    pp, ss = input().split(' ')
    p = int(pp) - 1

    if acc[p] == 0:
        if ss == 'WA':
            pena[p] += 1
        else:
            acc[p] = 1

for i in range(n):
    pena[i] = pena[i] * acc[i]

print(sum(acc), sum(pena))
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)
				else:
					for k in gr:
						if k > abs(x[i]-s) + abs(y[i]-t):
							gr.remove(k)

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			needH = -1
			for i in range(n):
				if h[i] > 0:
					tmp = h[i] + abs(x[i]-s) + abs(y[i]-t)
					if needH == -1:
						needH = tmp
					elif needH != tmp:
						needH = -2
						break
			if needH == -2:
				continue
			for i in range(n):
				if h[i] == 0 and needH > abs(x[i]-s) + abs(y[i]-t):
					needH = -2
					break
			if needH == -2:
				continue
			else:
				print("{} {} {}".format(s, t, needH))

if __name__ == '__main__':
	main()
W, H, N = map(int,input().split())
Map = np.ones((H, W),dtype = int)
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        Map[:,:x] = 0
    elif a == 2:
        Map[:,x:] = 0
    elif a == 3:
        Map[:y,:] = 0
    else:
        Map[y:,:] = 0
print(Map.sum())

### FIXED CODE ###

import numpy as np
W, H, N = map(int,input().split())
Map = np.ones((H, W),dtype = int)
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        Map[:,:x] = 0
    elif a == 2:
        Map[:,x:] = 0
    elif a == 3:
        Map[:y,:] = 0
    else:
        Map[y:,:] = 0
print(Map.sum())
rb = range(4)
rf = range(3)
rr = range(10)
rooms = [[[0 for i in rr] for j in rf]for k in rb]
while True:
    lx = int(raw_input())
    for i in range(lx):
        b,f,r,v = map(int, raw_input().split())
        rooms[b-1][f-1][r-1] += v

for i in rb:
    for j in rf:
        print '',
        for k in rr:
            print rooms[i][j][k],
        print
    if i < len(rb)-1:
        print '#' * 20

### FIXED CODE ###

rb = range(4)
rf = range(3)
rr = range(10)
rooms = [[[0 for i in rr] for j in rf]for k in rb]

lx = int(raw_input())
for i in range(lx):
    b,f,r,v = map(int, raw_input().split())
    rooms[b-1][f-1][r-1] += v

for i in rb:
    for j in rf:
        print '',
        for k in rr:
            print rooms[i][j][k],
        print
    if i < len(rb)-1:
        print '#' * 20
a, b, c = intpu().split()
print(c, a, b)

### FIXED CODE ###

a, b, c = input().split()
print(c, a, b)
N = int(input())

input_1 = input()
input_2 = input_1.split()

for k in range(N):
    A = map(int, input_2)

    def equal(num):
        return num / 1
    A = [equal(x) for x in A]

    ans = 0

    A.remove(A[k])

    for l in range(N - 1):
        for m in range(N - 1):
            if A[l] == A[m]:
                ans += 1
        
        ans -= 1

    ans = ans / 2

    print(int(ans))


### FIXED CODE ###

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

ans = (N * (N - 1) + M * (M - 1)) / 2

print(int(ans))
# 2125
# 方針．f(n)を求めるのがlog(N)で終わりそうだから普通に素直に実装すればいいのでは？
N = int(input())
X = list(input())

import math
# 最初にpopcount用のリストを作成する，そもそも2**(10**5)だから圧倒的に範囲が足らなかった
#L = [0 for i in range(int(math.log(N,2))+10)]
#for i in range(int(math.log(N,2))+10):
#    bi = list(str(bin(i)))
#    bi = bi[1:]
#    L[i] = bi.count('1')

# i番目のビットを反転させて,
dic={}
bn00 = X.count('1')
x00 = int(''.join(X),2)

for i in range(N):
    # ちゃんともとに戻してね，ということで本のビット
    b = int(X[i]) & 1
    bn = b ^ 1
    if bn:
        bn0 = bn00 + 1
    else:
        bn0 = bn00 - 1
    x0 = x00 % bn0
    xi = x0 - b * pow(2,N-1-i,bn0) + bn * pow(2,N-1-i,bn0)
    xi %= bn0
    num = xi
    count = 1
    while num > 0:
        bi = list(str(bin(num)))
        bi = bi[2:]
        st = ''.join(bi)
        if st in dic:
            bic = dic[st]
        else:
            bic = bi.count('1')
            dic[st] = bic
        num = num % bic
        count += 1
    print(count)


### FIXED CODE ###

# 2125
# 方針．f(n)を求めるのがlog(N)で終わりそうだから普通に素直に実装すればいいのでは？
# ただし最初だけは別に実装する必要がある
N = int(input())
X = list(input())

# i番目のビットを反転させて,
# やってることは似てるはずなのになんかうまく行かない
dic={}
bn00 = X.count('1')
x00 = int(''.join(X),2)
aa = x00 % (bn00+1)
if bn00-1==0:
    bb = 0
else:
    bb = x00 % (bn00-1)
for i in range(N):
    # ちゃんともとに戻してね，ということで本のビット
    b = int(X[i]) & 1
    bn = b ^ 1
    if bn:
        bn0 = bn00 + 1
        x0 = aa
    else:
        bn0 = bn00 - 1
        x0 = bb
    if bn0==0: # ビットが全く立っていないつまり0の時，0%0はエラーを起こすので，n%0もエラーを起こす
        print(0)
        continue
    if b: # もとのビットが立っている場合は減らす，ここの計算量が一番重いので計算量を削減してみる
        xi = x0 - b * pow(2,N-1-i,bn0)
    if bn:
        xi = x0 + bn * pow(2, N - 1 - i, bn0)
    xi %= bn0
    num = xi
    count = 1
    while num > 0:
        p = format(num,'b').count('1') # 10進数を２進数にかえるなら，これがいいのかも,int(str(i),2)を使うっていう手もあるけど周りくどい
        num = num % p
        count += 1
    print(count)
str = input().split()
num_list = []
for i in str:
  num_list.append(int(i))

ans = num_list[0]
LIMIT_NUM = 10**18
for i in range(1,len(num_list):
  ans *= num_list[i]

if ans > LIMIT_NUM:
               print(-1)
else:
               print(ans)

### FIXED CODE ###

def main(): 
  N = int(input())
  str_num = input().split()

  num_list = []
  for i in str_num:
    num_list.append(int(i))

  num_list.sort(reverse=True)

  ans = num_list[0]

  LIMIT_NUM = 10**18

  if 0 in num_list:
    print(0)
    return

  for i in range(1,N):
    ans *= num_list[i]
    if ans > LIMIT_NUM:
      print(-1)
      return

  print(ans)


main()