Harryxun/stf_run huggingface dataset:
def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance + edge_size) % 2)
            dfs(next_node, distance + edge_size)

N = int(input())

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

ans = [-1] * N
dfs(0, 0)
print(*ans, sep='\n')

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)

def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance + edge_size) % 2)
            dfs(next_node, distance + edge_size)

N = int(input())

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

ans = [-1] * N
dfs(0, 0)
print(*ans, sep='\n')
import numpy as np

S = input()
S_int = int(S)

tile_color = []

keta = len(S)
for i in range(keta):
    if S_int/10 == int(S_int/10):
        tile_color.insert(0, '0')
    else:
        tile_color.insert(0, '1')
    S_int = int(S_int/10)

length_of_S = len(tile_color)

candidate_1 = np.zeros((1,length_of_S))
candidate_1[0,0::2] = 1
candidate_2 = np.zeros((1,length_of_S))
candidate_2[0,1::2] = 1

tile_color = [int(n) for n in tile_color]

distance = [np.sum(np.abs(tile_color - candidate_1[0,:])), np.sum(np.abs(tile_color - candidate_2[0,:]))]

print(int(min(distance)))

### FIXED CODE ###

import numpy as np

S = input()

tile_color = []
for i in S:
    tile_color.append(int(i))

candidate = np.zeros((2,len(S)))
candidate[0, 0::2] = 1
candidate[1, 1::2] = 1

distance = [np.sum(np.abs(candidate[0,:] - tile_color)), np.sum(np.abs(candidate[1,:] - tile_color))]

print(int(min(distance)))
A, B, C = list(int, input().split())
if (A+B) >=C:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

A, B, C = map(int, input().split())
if (A+B) >=C:
	print("Yes")
else:
	print("No")
A, B = map(int, input())
if 0<A<10 and 0<B<10:
  print(A*B)
else:
  print(-1)

### FIXED CODE ###

A, B = map(int, input().split())
if 0<A<10 and 0<B<10:
  print(A*B)
else:
  print(-1)
import numpy as np

n, k = (int(x) for x in input().split())
p = np.array(int(x) for x in input().split())
sump = []

for i in range(n - k + 1):
    sump.append(sum(p[i: k + i], k))
    sump.extend(np.sum(p[i: k + i]))

print((max(sump) + k) / 2)


### FIXED CODE ###

import numpy as np

n, k = (int(x) for x in input().split())
p = np.array(list(int(x) for x in input().split()))

p = (p + 1) / 2

sump = []
e = []
s = 0

for i in range(len(p)):
    s += p[i]
    sump.append(s)

sump.insert(0, 0)
sump = np.array(sump)

for i in range(n - k + 1):
    e.append(sump[i + k] - sump[i])


print(max(e))
def main():
	N, X, M = [int(a) for a in input().split(" ")]
	used_r = [0] * (M - 1)
	r = [-1, X]
	used_r[X] = 1
	loop_start_elm = -1
	loop_start_n_2 = -1
	for i in range(M):
		A = r[-1]
		B = (A * A) % M
		if used_r[B] == 0:
			r.append(B)
			used_r[B] = 1
		else:
			loop_start_elm = B
			loop_start_n_2 = i + 2
			break
	loop_start_n = r.index(B)

	s1 = sum(r[:loop_start_n]) + 1
	s2 = sum(r[loop_start_n:loop_start_n_2])
	loop_len = loop_start_n_2 - loop_start_n
	loop_n = int((N - loop_start_n + 1) / loop_len)
	rest_n = (N - loop_start_n + 1) % loop_len
	s3 = sum(r[loop_start_n:(loop_start_n + rest_n)])
	print(s1 + s2 * loop_n + s3)

main()



### FIXED CODE ###

def main():
	N, X, M = [int(a) for a in input().split(" ")]
	used_r = [0] * M
	r = [-1, X]
	used_r[X] = 1
	loop_start_elm = -1
	loop_start_n_2 = -1
	for i in range(M):
		A = r[-1]
		B = (A * A) % M
		if used_r[B] == 0:
			r.append(B)
			used_r[B] = 1
		else:
			loop_start_elm = B
			loop_start_n_2 = i + 2
			break
	loop_start_n = r.index(B)

	s1 = sum(r[:loop_start_n]) + 1
	s2 = sum(r[loop_start_n:loop_start_n_2])
	loop_len = loop_start_n_2 - loop_start_n
	loop_n = int((N - loop_start_n + 1) / loop_len)
	rest_n = (N - loop_start_n + 1) % loop_len
	s3 = sum(r[loop_start_n:(loop_start_n + rest_n)])
	print(s1 + s2 * loop_n + s3)

main()
from collections import deque

string = input()
s = deque(string)
iteration = int(input())
reverse = 1

for c in range(0,iteration):
    sousa = input().split()
    #操作１のとき
    if sousa[0] == "1":
        reverse = reverse*(-1)
    #操作２を行うとき
    elif sousa[1] == "1":
        if reverse == 1:
            s.appendleft(sousa[2])
        else:
            s.append(sousa[2])
    else:
        if reverse == 1:
            s.append(sousa[2])
        else:
            s.appendleft(sousa[2])

if reverse == -1:
    s = s[::-1]

result = "".join(s)
print(result)


### FIXED CODE ###

from collections import deque
string = input()
s = deque(string)
iteration = int(input())
reverse = 1

for c in range(0,iteration):
    sousa = input().split()
    #操作１のとき
    if sousa[0] == "1":
        reverse = reverse*(-1)
    #操作２を行うとき
    elif sousa[1] == "1":
        if reverse == 1:
            s.appendleft(sousa[2])
        else:
            s.append(sousa[2])
    else:
        if reverse == 1:
            s.append(sousa[2])
        else:
            s.appendleft(sousa[2])

result = "".join(s)
if reverse == -1:
    result = result[::-1]


print(result)
N,K, M = map(int,input().split())
A = list(map(int,input().split()))

ans = M*N-sum(A)

if ans > K:
    print(-1)
elif ans < 0:
    print(0)
else:
    print(ans)



### FIXED CODE ###

a = input()
b = chr(ord(a)+1)
print(b)
N = input(int())
ans = 1
i = []
 
list = [i for i in input().split()]
 
for i in range(N-1):
  ans = ans * i
 
if ans > 10**18:
    ans = "-1"
 
print(str(ans))

### FIXED CODE ###

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

ans = 1

if 0 in a:
    print("0")
    exit()

for i in a:
    ans *= i

    if ans > 10**18:
        print("-1")
        exit()
        
print(ans)
import math
N = int(input())
T = list(int(input()) for _ in range(N))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // math.gcd(ans, T[i])
print(ans)

### FIXED CODE ###

n =int(input())
import fractions
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // fractions.gcd(ans, t)
print(ans)
hh, ww = map(int, input(),split())
h, w = map(int, input(),split())
s = hh*ww - h*ww - hh*w + hh*ww
print(s)

### FIXED CODE ###

hh,ww = map(int, input().split())
h, w = map(int, input().split())
s = hh*ww - h*ww - hh*w + h*w
print(s)
import math
N=input()
s = list( map(int , input().split()) )
ans = s[0]
count = 0
for i in range(1,N-1):
 ans = math.gcd(ans,s[i])
while i < pow(10,9):
 if ans%2 == 0:
  count +=1
  ans = ans/2
 else:
  break
print(count)

### FIXED CODE ###

import fractions
N=int(input())
s = list( map(int , input().split()) )
ans = s[0]
count = 0
for i in range(1,N):
 ans = fractions.gcd(ans,s[i])
while i < pow(10,9):
 if ans%2 == 0:
  count +=1
  ans = ans/2
 else:
  break
print(count)
s=input()
if s[0]=='S':
    print('Cloudy')
else if s[0]=='C':
    print('Rainy')
else:
    print('Suuny')

    

### FIXED CODE ###

s=input()
if s[0]=='S':
    print('Cloudy')
elif s[0]=='C':
    print('Rainy')
else:
    print('Sunny')
T = input()
T = list(T)
N = len(T)
for i in range(N):
  if T[i] =='?' and T[i+1]=='D':
    del T[i]   
    T.insert(i,'P')
  elif T[i] =='?' and T[i+1]=='?':
    del T[i]   
    T.insert(i,'P')
  elif T[i] =='?': 
    del T[i] 
    T.insert(i,'D')
print("".join(T))

### FIXED CODE ###

S = input()
s=[]
for i in S:
    s.append(i)
t = []
for i in range(len(s)):
  if s[i] == '?':
    t.append('D')
  else:
    t.append(s[i])
Strt = "".join(t)
print(Strt)
# -*- coding: utf-8 -*-

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

xor_sum = 0
for i in range(N-1):
  for j in range(i+1, N):
    xor_sum += (A[i]^A[j])

dst = xor_sum % (10**9+7)
print(dst)

### FIXED CODE ###

import numpy as np

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

mod = 10 ** 9 + 7
s = 0

for i in range(60):# Aは2の6乗より小さい
    c = np.count_nonzero(A & 1) # 最下位のbitで0じゃないものの個数
    s += 2 ** i * c * (N - c) # https://qiita.com/ZhangChaoran/items/0d59eb5c95cd9414801d
    A >>= 1 #　1bitずつ右にずらす。これを繰り返し続ける
print(s % mod)
#D
from scipy.misc import comb
n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
    print((comb(k-1,i-1,exact=True)*comb(n-k+1,i,exact=True))%mod)

### FIXED CODE ###

#D
from scipy.misc import comb
n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
    print(int(comb(k-1,i-1,exact=True)*comb(n-k+1,i,exact=True))%mod)
from heapq import *
import numpy as np
n,m,s,t=map(int,input().split())
a=[[]for i in range (n+1)]
b=[[]for i in range(n+1)]
for i in range(m):
    p,q,r,g=map(int,input().split())
    a[p].append([q,r])
    a[q].append([p,r])
    b[p].append([q,g])
    b[q].append([p,g])
def f(x,r):
    p=[float("INF")]*(n+1)
    p[x],q=0,[[0,x]]
    while q:
        y,z=heappop(q)
        for i,j in r[z]:
            if p[i]>y+j:
                p[i]=y+j
                heappush(q,[p[i],i])
    return p[1:]
s1,t1=f(s,a),f(t,b)
p=[]
for i in range(n):
    p.append((s1[i]+t1[i],i+1))
p,e=sorted(p),0
for i in range(n):
    while p[e][1]<=i: e+=1
    print(10**15-p[e][0])

### FIXED CODE ###

from heapq import heappush,heappop
n,m,s,t=map(int,input().split())
a,b=[[]for i in range (n+1)],[[]for i in range(n+1)]
for i in range(m):
    p,q,r,g=(int(i) for i in input().split())
    a[p].append((q,r))
    a[q].append((p,r))
    b[p].append((q,g))
    b[q].append((p,g))
def f(x,r):
    p=[float("inf")for i in range(n+1)]
    p[x],q=0,[[0,x]]
    while q:
        y,z=heappop(q)
        for i,j in r[z]:
            if p[i]>y+j:
                p[i]=y+j
                heappush(q,[p[i],i])
    return p
s1,t1,p=f(s,a),f(t,b),[]
for i in range(1,n+1):
    p.append((s1[i]+t1[i],i))
p,e=sorted(p),0
for i in range(n):
    while p[e][1]<=i: e+=1
    print(10**15-p[e][0])
n = int(input())
numlist = list(map(int, input().split()))
if 0 in numlist:
    print(0)
else:
    ans = 1
    for i in numlist:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
	print(ans)

### FIXED CODE ###

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

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

if N == K:
    print(1)
else:
    for i in range(K):
        if N-K < i-1:
            break
        print(comb(N-K+1, i+1)*comb(K-1, i) % 1000000007)

### FIXED CODE ###

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

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


for i in range(K):
    if N-K < i:
        print(0)
    else:
        print(comb(N-K+1, i+1)*comb(K-1, i) % 1000000007)
n = int(input())
A = [0]*(10**9+5)
for i in range(n):
    a = int(input())
    A[a-1]+=1
    A[a-1]%=2
print(sum(A))


### FIXED CODE ###

n = int(input())
A = {}
for i in range(n):
    a = int(input())
    A[a] = A.get(a, 0)+1
    A[a] %= 2
s = 0
for v in A.values():
    s += v
print(s)
import sys


def process():
    data = []
    for line in get_data():
        line = line.split()
        if len(line) == 2:
            if line[0] == line[1] == '0':
                data = []
                continue
            H = int(line[0])
            W = int(line[1])
        elif len(line) == 0:
            pass
        else:
            data.append(line[0])
            if len(data) == H:
                field = create_field(H, W)
                print search(H, W, data, field)


def search(H, W, data, field):
    count = 0
    for i in xrange(H):
        for j in xrange(W):
            if field[i][j] == 0:
                continue
            _search(i, j, H, W, data[i][j], data, field)
            count += 1
    return count


def _search(i, j, H, W, cell, data, field):
    field[i][j] = 0
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if field[a][b] == 0:
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data, field)
    return


def create_field(H, W):
    field = []
    for i in xrange(H):
        raw = []
        for j in xrange(W):
            raw.append(1)
        field.append(raw)
    return field


def get_data():
    return [line.strip() for line in sys.stdin.readlines()]


process()

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()
H, N = map(int, input().split())
A = list(map(int, input().split()))
sum = 0

for val in A
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")


### FIXED CODE ###

H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H:
	print("Yes")
else:  
	print("No")
a, b = list(map, int(input().split()))
if a+b >=10:
  print ('error')
else:
  print(a+b)

### FIXED CODE ###

a, b =map(int, input().split())
if a+b>=10:
  print('error')
else:
  print(a+b)
n,y=map(int,input().split())
a=10000
b=5000
c=1000
sum_money=y
for i in range(0,n+1):
  for j in range(0,n+1-i):
    k=n-i-j and k>=0
    if sum_money==a*i+b*j+c*k:
      print(i,j,k)
      break
  else:
    continue
  break
else:
	print("-1","-1","-1")


### FIXED CODE ###

n,y=map(int,input().split())
a=10000
b=5000
c=1000
sum_money=y
for i in range(0,n+1):
  for j in range(0,n+1-i):
    k=n-i-j
    if sum_money==a*i+b*j+c*k and k>=0:
      print(i,j,k)
      break
  else:
    continue
  break
else:
	print("-1","-1","-1")
n,m=map(int, input().split())

k=[]

for i in range(m):
  if (m%i==0) and (m//i <= n):
    k.append(i)
    
print(max(k))    

    





### FIXED CODE ###

import math

n,m=map(int,input().split())
if n==1:
        print(m)
else:
        l=[]
        for i in range(1,math.floor(m**0.5)+1):
           if m%i==0 and i<=m//n:
                l.append(i)
                if m//i<=m//n:
                        l.append(m//i)
        l.sort()
        print(l[-1])
n = int(input())
t,a = map(int,input().split())
H_list = list(map(int,input().split()))
t_list = [t-h*0.006 for h in H_list ]
a_list = [abs(a-x) for x in temp_list]
print(a_list.index(min(a_list))+1)   

### FIXED CODE ###

n = int(input())
t,a = map(int,input().split())
H_list = list(map(int,input().split()))
temp_list = [t-h*0.006 for h in H_list ]
ans_list = [abs(a-x) for x in temp_list]
ans = min(ans_list)
print(ans_list.index(ans)+1)
import bisect

N=int(input())

E=[]
O=[]

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

for i in range(len(a)):
    if a[i]%2==0:
        E.append(a[i])
    else:
        O.append(a[i])
        
E.sort()
O.sort()

ans=0
for e in range(len(E)):
    t=0
    while E[len(E)-1-e]>2**t:
       t=t+1
       #print(t)
    if E[bisect.bisect_left(E,2**t-E[len(E)-1-e])]+E[len(E)-1-e]==2**t:
        ans+=1
        del E[bisect.bisect_left(E,2**t-E[len(E)-1-e])]
        
for o in range(len(O)):
    t=0
    while O[len(O)-1-o]>2**t:
       t=t+1
       #print(t)
    if O[bisect.bisect_left(O,2**t-O[len(O)-1-o])]+O[len(O)-1-o]==2**t:
        ans+=1
        del O[bisect.bisect_left(O,2**t-O[len(O)-1-o])]
print(ans)


### FIXED CODE ###

import bisect
N=int(input())
A=list(map(int,input().split()))
A.sort()
A.append(999999999999999)
B=[]
for i in range(1,35):
    B.append(2**i)
ans=0
for i in range(N):
    if A[N-1-i]==int(A[N-1-i]):
        for j in range(len(B)):
            if A[N-1-i]<B[j]:
                break
        if A[bisect.bisect_left(A,B[j]-A[N-1-i])]==B[j]-A[N-1-i]:
            if bisect.bisect_left(A,B[j]-A[N-1-i])<N-1-i:
                A[bisect.bisect_left(A,B[j]-A[N-1-i])]-=0.1
                A[N-1-i]+=0.1
                ans+=1
print(ans)
N  = int(input())
slist = [input() for _ in range(N)]
abc = 'abcdefghijklmnopqrstuvwxyz'
l = [50] * 26
ans = ''
for i in range(N):
    for s in slist:
        l[i] = min(l[i],s.count(abc[i]))
for j in range(N):
    ans = ans + (abc[j] * l[j])
print(ans)
    

### FIXED CODE ###

N  = int(input())
slist = [input() for _ in range(N)]
abc = 'abcdefghijklmnopqrstuvwxyz'
l = [50] * 26
ans = ''
for i in range(26):
    for s in slist:
        l[i] = min(l[i],s.count(abc[i]))
for j in range(26):
    ans = ans + (abc[j] * l[j])
print(ans)
n,m = int(input().split())

if m == n:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

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

if m == n:
  print('Yes')
else:
  print('No')
n = int(input())
h = list(map(int,input().split(" ")))

plsl = []
plsn = 0
for i in range(n-1):
    if h[i]>= h[i+1] and i == n-1:
        plsn += 1
        # print(plsn)
        plsl.append(plsn)
        # print(plsl)
    elif h[i]>= h[i+1] and i < n-1:
        plsn += 1
        # print(plsn)
    else:
        plsl.append(plsn)
        # print(plsl)
        plsn = 0
        # print(plsn)
plsl.sort(reverse = True)
print(plsl[0])

### FIXED CODE ###

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

v.sort()
# print(v)
w = []

w0 = (v[0] + v[1])/2
w.append(w0)

for i in range(1,n-1):
    y = (v[i+1] + w[i-1])/2
    w.append(y)
    # print(w)
# print(w)
print(w[n-2])
S=input()
count=0
for i in range(2):
  S[i]==S[i+1]
  count+=1
  bleak
if count==2:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S=input()
count=0
for i in range(2):
  if S[i]==S[i+1]:
    count+=1
if count==2:
  print("No")
else:
  print("Yes")
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque


def main():
    n, p = map(int, input().split())

    div = []
    c = 1
    while c * c <= p:
        if not p % c:
            div.append(c)
            if c * c != p:
                div.append(p//c)
        c += 1

    div.sort()
    ans = 1
    for d in div:
        pp = pow(d, n)
        if pp > p:
            break
        if not p % pp:
            ans = max(ans, d)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

N, P = map(int, input().split())
res = {}


def pf(n):
    c = 2
    while c * c <= n:
        while not n % c:
            res[c] = res.get(c, 0) + 1
            n //= c
        c += 1

    if n != 1:
        res[n] = 1


def main():
    pf(P)

    ans = 1
    for d in res:
        ans *= pow(d, res[d]//N)

    print(ans)


if __name__ == '__main__':
    main()
import math
R = lambda : map(int,input().split())
n,d = R()
xs = [list(R()) for _ in range(n)]

def dist(y,z):
    return math.sqrt(sum([(y[i]-z[i])**2 for i in range(d)]))


count = 0
for i in range(n):
    for j in range(i+1,n):
        d = dist(xs[i],xs[j])
        if int(d)==d:
            count+=1
print(count)

### FIXED CODE ###

# import atexit
# import io
# import sys
#
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math

N, D = map(int, input().split())
Xs = [list(map(int, input().split())) for _ in range(N)]


def dist(y, z):
    return math.sqrt(sum([(y[i] - z[i]) * (y[i] - z[i]) for i in range(D)]))


count = 0
for i in range(N):
    for j in range(i + 1, N):
        d = dist(Xs[i], Xs[j])
        if int(d) == d:
            count += 1

print(count)
N = int(input())
ans = 0
ls = 0
rs = 0
lr = 0
for _ in range(N):
    s = str(input())
    if "AB" in s:
        ans += 1
    if s[-1] == "A" and s[0] == "B":
        lr += 1
    elif s[-1] == "A":
        rs += 1
    elif s[0] == "B":
        ls += 1
if ls == 0 and rs == 0:
    ans += lr - 1 
elif ls == 0 and rs != 0:
    ans += lr
elif ls != 0 and rs == 0:
    ans += lr
else:
    lr += 1
    rs -= 1
    ls -= 1
    ans += lr
    ans += (rs+ls)//2
#ans += lr
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(a):
    if i + b > a:
        break
    else:
        ans += 1
print(ans)
a, b, c, d=map(int,input().split)
k1=int(abs(a-b))
k2=int(abs(a-c))
k3=int(abs(b-c))
print("Yes" if k2<=d or k1<=d and k3<=d else "No")

### FIXED CODE ###

a, b, c, d=map(int,input().split())
k1=abs(a-b)
k2=abs(a-c)
k3=abs(b-c)
if k2<=d:
  print("Yes")
elif k1<=d and k3<=d:
  print("Yes")
else:
  print("No")
class Node:
    def __init__(self, index):
        self.count = 0
        self.next = []
        self.index = index


def f(node, count, index):
    node[index].count += count
    for i in node[index].next:
        f(node, count, i)


N, Q = map(int, input().split())
node = [Node(i) for i in range(N)]
for i in range(N - 1):
    fr, to = map(int, input().split())
    node[fr - 1].next.append(to - 1)

for i in range(Q):
    fr, c = map(int, input().split())
    f(node, c, fr - 1)

print(' '.join([str(n.count) for n in node]))


### FIXED CODE ###

class Node:
    def __init__(self, index):
        self.count = 0
        self.fr = -1
        self.index = index


N, Q = map(int, input().split())
node = [Node(i) for i in range(N)]
for i in range(N - 1):
    fr, to = map(int, input().split())
    node[to - 1].fr = fr - 1

for i in range(Q):
    fr, c = map(int, input().split())
    node[fr - 1].count += c

print(node[0].count, end=' ')

for i in range(1, N):
    node[i].count += node[node[i].fr].count
    if not i == N:
        print(node[i].count, end=' ')
    else:
        print(node[i].count)
N = input(int())
ans = 1
i = []
 
list = [i for i in input().split()]
 
for i in range(N - 1):
  ans = ans * i
 
  if ans > 10**18:
    ans = -1
 
print(str(ans))

### FIXED CODE ###

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

ans = 1

if 0 in a:
    print("0")
    exit()

for i in a:
    ans *= i

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