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

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

route = [1]
for i in range(K):
    next_town = al[route[i]-1]
    if next_town in route:
        loop_start = route.index(next_town)
        loop_end = len(route)
        loop_length = loop_end - loop_start
        if K >= loop_end:
            amari = (K - loop_start)%loop_length
            ans = route[loop_start + amari]
            #print(route)
            print(ans)
            exit()
        else:
            print(next_town)
            break
    else:
        route.append(next_town)

ans = route[-1]
print(ans)


### FIXED CODE ###

from collections import defaultdict


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


N, K = inpl()
aa = inpl()

s = 1

route = [s]
ed = set([s])

for i in range(1, K + 1):
    s = aa[s - 1]
    if s in ed:
        Li = route.index(s)
        Ri = len(route)
        idx = Li + (K - Li) % (Ri - Li)
        print(route[idx])
        break
    else:
        route.append(s)
        ed.add(s)
        continue
else:
    print(s)
### BUGGY CODE ###

# from pprint import pprint
# import math
# import collections

# n = int(input())
R, G, B, N = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

max_r, max_g, max_b = N // R, N // G, N // B
ans = []

r, g, b = 0, 0, 0
cnt = 0
for r in range(max_r + 1):
    if R * r > N:
        break
    for g in range(max_g + 1):
        if R * r + G * g > N:
            break
        x = (N - (R * r + G * g))
        if x % B == 0 and x >= 0:
            b = x // B
            a = (r, g, b)
            cnt += 1
            # ans.append(a)

# print(len(ans))
print(cnt)


### FIXED CODE ###

# from pprint import pprint
# import math
# import collections

# n = int(input())
R, G, B, N = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

# max_r, max_g, max_b = N // R, N // G, N // B
ans = []

r, g, b = 0, 0, 0
cnt = 0

max_r = N // R
for r in range(max_r + 1):
    if R * r > N:
        break

    max_g = (N - R * r) // G

    for g in range(max_g + 1):
        if R * r + G * g > N:
            break
        x = (N - (R * r + G * g))
        if x % B == 0 and x >= 0:
            # b = x // B
            # a = (r, g, b)
            cnt += 1
            # ans.append(a)

# print(len(ans))
print(cnt)
### BUGGY CODE ###

def dfs(X,Y,ch):
	stack.append([X,Y])
	print stack
	field[X][Y] = '.'
	while len(stack) != 0:
		x,y = stack.pop()
		for i in range(4):
				nx = x+moveY[i]
				ny = y+moveX[i]
				if (nx >= 0 and ny >= 0) and(nx < H and ny < W) and field[nx][ny] == ch:
					if field[nx][ny] == '#' or field[nx][ny] == '*'or field[nx][ny] == '@':
						field[nx][ny] = '.'
						stack.append([nx,ny])
						print stack
stack = []
moveY = [-1,0,1,0]
moveX = [0,1,0,-1]
while True:
	H,W = map(int,raw_input().split(' '))
	if H == 0 and W == 0:
		break
	field = ['' for i in range(H)]
	h = 0
	for i in range(H):
		field[i] = list(raw_input())
	correct =0
	for i in range(H):
		for j in range(W):
			if field[i][j] == '@' or field[i][j] == '#'or field[i][j] == '*':
				dfs(i,j,field[i][j])
				correct += 1
	print correct

### FIXED CODE ###

def dfs(X,Y,ch):
	stack.append([X,Y])
	field[X][Y] = '.'
	while len(stack) > 0:
		x,y = stack.pop()
		for i in range(4):
				nx = x+moveY[i]
				ny = y+moveX[i]
				if nx < 0 or ny < 0 or nx >= H or ny >= W or field[nx][ny] != ch:
					continue
				if field[nx][ny] == '#' or field[nx][ny] == '*'or field[nx][ny] == '@':
					field[nx][ny] = '.'
					stack.append([nx,ny])
stack = []
moveY = [-1,0,1,0]
moveX = [0,1,0,-1]
while True:
	H,W = map(int,raw_input().split(' '))
	if H == 0 and W == 0:
		break
	field = [list(raw_input()) for i in range(H)]
	correct =0
	for i in range(H):
		for j in range(W):
			if field[i][j] == '@' or field[i][j] == '#'or field[i][j] == '*':
				dfs(i,j,field[i][j])
				correct += 1
	print correct
### BUGGY CODE ###

n = input()
s = raw_input()

MOD = 10**9+7
dp = [1]
for i in xrange(n):
    dp2 = [0]*(i+2)
    for j in xrange(i+1):
        dp2[j+1] += dp[j]
        dp2[j+1] %= MOD
    for j in xrange(1, i+1):
        dp2[j-1] += 2*dp[j]
        dp2[j-1] %= MOD
    dp2[0] = (dp2[0] + dp[0]) % MOD
    dp = dp2
print dp2[len(s)]

### FIXED CODE ###

n = input()
s = raw_input()

MOD = 10**9+7
dp = [1]
for i in xrange(n):
    dp2 = [0]*(i+2)
    for j in xrange(i+1):
        dp2[j+1] += dp[j]
        dp2[j+1] %= MOD
    for j in xrange(1, i+1):
        dp2[j-1] += 2*dp[j]
        dp2[j-1] %= MOD
    dp2[0] = (dp2[0] + dp[0]) % MOD
    dp = dp2
print dp2[len(s)]
### BUGGY CODE ###

import sys

def findminsum(lst,K,N):
    inf=10**10
    dp=[[inf]*N for s in range(K+1)]
    for s in range(K+1):
        for j in range(N):
            if j==0 and s<=lst[j]:
                dp[s][j]=lst[0]
            elif s>lst[j] and j>0:
                dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
            elif s<=lst[j] and j>0:
                dp[s][j]=min(lst[j],dp[s][j-1])
    # print(lst)
    # print(dp[0][:])
    # print(dp[1][:])
    # print(dp[K][:])
    return dp[K][N-1]

def main():
    N,K=map(int,sys.stdin.readline().strip().split())
    cards=list(map(int,sys.stdin.readline().strip().split()))
    cards=list(filter(lambda x:x<K,cards))
    cards.sort()
    N=len(cards)
    nn=0
    for i in range(N):
        if cards[i]<K:
            c=cards[i]
            cards[i]=0
            if findminsum(cards,K-c,N)>=K:
                nn+=1
            cards[i]=c
        else:
            break
    print(nn)

if __name__=='__main__':
    main()


### FIXED CODE ###

#4 9
#1 3 5 6
#の時に1（正解は0）と出力されるがACになる

N, K = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from heapq import heappop, heappush
xs, ys, xt, yt = map(int, input().split())
N = int(input())
cost = [[0] * (N + 2) for i in range(N + 2)]
D = []
for i in range(N):
    x, y, r = map(int, input().split())
    D.append((x, y, r))
D.append((xs, ys, 0))
D.append((xt, yt, 0))

for i in range(len(D)):
    for j in range(len(D)):
        cost[i][j] = max(0, ((D[i][0] - D[j][0]) ** 2 + (D[i][1] - D[j][1]) ** 2) ** 0.5 - (D[i][2] + D[j][2]))

INF = float('inf')
d = [INF] * (N + 2)
d[N] = 0
que = [(N, 0.0)]
while que:
    v, dist = heappop(que)
    if d[v] < dist:
        continue
    for w in range(N + 2):
        if d[w] > d[v] + cost[v][w]:
            d[w] = d[v] + cost[v][w]
            heappush(que, (w, d[w]))

print(d[N + 1])

### FIXED CODE ###

import sys
from math import sqrt
input = sys.stdin.readline
from heapq import heappop, heappush
xs, ys, xt, yt = map(int, input().split())
N = int(input())
INF = float('inf')
cost = [[INF] * (N + 2) for i in range(N + 2)]
D = [(xs, ys, 0)]
for i in range(N):
    x, y, r = map(int, input().split())
    D.append((x, y, r))
D.append((xt, yt, 0))

for i in range(N + 2):
    for j in range(i + 1, N + 2):
        k = max(0, sqrt((D[i][0] - D[j][0]) ** 2 + (D[i][1] - D[j][1]) ** 2) - D[i][2] - D[j][2])
        cost[i][j] = k
        cost[j][i] = k

visit = [0] * (N + 2)
visit[0] = 1
d = [INF] * (N + 2)
d[0] = 0
que = [(0, 0)]
while que:
    dist, v = heappop(que)
    if d[v] < dist:
        continue
    if v == N + 1:
        print(d[v])
        exit()
    visit[v] = 1
    for w in range(N + 2):
        if visit[w] == 0 and w != v and d[w] > d[v] + cost[v][w]:
            d[w] = d[v] + cost[v][w]
            heappush(que, (d[w], w))
### BUGGY CODE ###

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

def solve(a):
	l = {}
	count = 0
	while 0 == a % 2:
		a //= 2
		count += 1
	else:
		if count:
			l[2] = count

	for n in range(3, a // 2 + 1, 2):
		if a == 1:
			return l
		if a < n:
			l[a] = 1
			return l

		count = 0
		while 0 == a % n:
			a //= n
			count += 1
		else:
			if count:
				l[n] = count
	return l

l = solve(P)
#print(l)

keys = sorted(l, reverse=True)
r = 1
for key in keys:
	if N <= l[key]:
		r *= key ** (l[key] // N)
print(r)


### FIXED CODE ###

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

def solve(a):
	l = {}
	count = 0
	while 0 == a % 2:
		a //= 2
		count += 1
	else:
		if count:
			l[2] = count

	for n in range(3, int(a ** 0.5) + 1, 2):
		if a == 1:
			return l

		count = 0
		while 0 == a % n:
			a //= n
			count += 1
		else:
			if count:
				l[n] = count
	else:
		if 1 != a:
			l[a] = 1
	return l

l = solve(P)
#print(l)

keys = sorted(l, reverse=True)
r = 1
for key in keys:
	if N <= l[key]:
		r *= key ** (l[key] // N)
print(r)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np


def canReach(src, dst):
    a = (dst[0] - src[0]) - np.sum(np.abs(src-dst)[1:3])
    if a >= 0 and a % 2 == 0:
        return True
    return False


N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])
available = True
dst = np.vstack((np.array([0, 0, 0]),dst))

for n in range(N):
    if not canReach(dst[n], dst[n+1]):
        available = False
        break

if available:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")
### BUGGY CODE ###

from collections import *
H,W=map(int,input().split())
S=[input() for i in range(H)]
count=0
stack=deque([[0,0,0,S[0][0]=="#"]])
RuiW=[[0] for i in range(H)]
RuiH=[[0] for i in range(W)]
if S[0][0]=="#":
    RuiW[0][0]=1
    RuiH[0][0]=1

for h in range(H):
    flag=0
    for w in range(1,W):
        RuiW[h].append(RuiW[h][-1]+bool(S[h][w]=="#" and S[h][w-1]=="."))
for w in range(W):
    for h in range(1,H):
        RuiH[w].append(RuiH[w][-1]+bool(S[h][w]=="#" and S[h-1][w]=="."))

Range=range(1,100)
idle_max=10**9
visited=[[idle_max for i in range(W)] for m in range(H)]
#print(RuiW)
#print(RuiH)
while stack:
    h,w,m,Flag=stack.popleft()
    for i in Range:
        if h+i>=H:
            break
        M=RuiH[w][h+i]-(RuiH[w][h]-RuiH[w][h]%2)+m

        if visited[h+i][w]>M:
            visited[h+i][w]=M
            stack.append([h+i,w,M,0])
    for i in Range:
        if w+i>=W:
            break
        M=RuiW[h][w+i]-(RuiW[h][w]-RuiW[h][w]%2)+m
        if visited[h][w+i]>M:
            visited[h][w+i]=M
            stack.append([h,w+i,M,0])
#print(visited)
print(visited[-1][-1])


### FIXED CODE ###

from collections import *
from heapq import *
H,W=map(int,input().split())
S=[input() for i in range(H)]
if S[0][0]=="#":
    count=1
else:
    count=0
idlemax=10**5
visited=[[idlemax for w in range(W)] for h in range(H)]
stack=deque([[0,0,bool(S[0][0]=="#")*1,bool(S[0][0]=="#")*1]])
while stack:

    h,w,m,flag=stack.popleft()
    if m>visited[h][w]:
        continue
    for y,x in [[0,1],[1,0]]:
        Y=h+y;X=w+x
        if Y<H and X<W:
            if flag:
                if visited[Y][X]>m:
                    if S[Y][X]==".":
                        nflag=0
                    else:
                        nflag=1
                    visited[Y][X]=m
                    stack.append([Y,X,m,nflag])
            else:
                if S[Y][X]=="#":
                    nflag=1
                    M=m+1
                else:
                    nflag=0
                    M=m
                if visited[Y][X]>M:
                    visited[Y][X]=M
                    stack.append([Y,X,M,nflag])
#print(visited)
print(visited[-1][-1])
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 1
for a in A:
    ans *= a
if ans > 10 ** 18:
    print(-1)
else:
    
    print(ans)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 1
# exit()
A.sort()
# print(A)
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
else:

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

from heapq import heappop, heappush

N, K = map(int, input().split())
digests = list(map(int, input().split()))
foods = list(map(int, input().split()))
foods.sort()
digests.sort(reverse=True)
hq = []
for i in range(N):
  heappush(hq, (-digests[i]*foods[i], digests[i], foods[i]))
for _ in range(K):
  cost, digest, food = heappop(hq)
  if cost == 0:
    heappush(hq, (0, 0, 0))
    break
  heappush(hq, (-(digest-1)*food, digest-1, food))
ans = 0
max_c, digest, food = heappop(hq)
print(-max_c)

### FIXED CODE ###

N, K = map(int, input().split())
costs = list(map(int, input().split()))
foods = list(map(int, input().split()))
foods.sort()
costs.sort(reverse=True)

def can_eat(x):
  count = 0
  for i in range(N):
    count += max(0, costs[i]-x//foods[i])
  return count <= K

l, r = -1, 10**12+1
while r-l > 1:
  mid = (l+r)//2
  if can_eat(mid):
    r = mid
  else:
    l = mid
print(r)
### BUGGY CODE ###

import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7
def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
s = inl()
t = inl()
dp = [ [0] * (m+1) for i in range(n) ]
dp[0][0] = 1 if s[0]==t[0] else 0
for i in range(1,n):
    dp[i][0] = dp[i-1][0] + (1 if s[i]==t[0] else 0)
for j in range(1,m):
    dp[0][j] = dp[0][j-1] + (1 if s[0]==t[j] else 0)

sh = defaultdict(list)
for i in range(1,n):
    sh[s[i]].append(i)

for i in range(1,n):
    for j in range(1,m):
        x = dp[i][j-1]
        for z in sh[t[j]]:  # s[z]==t[j]
          if z<=i:
            x = (x+dp[z-1][j-1]+1)%R  # z>0
        if t[j]==s[0]:
            x += 1
        dp[i][j] = x

if DBG:
    for i in range(n):
        print(dp[i])
print((dp[n-1][m-1]+1)%R)


### FIXED CODE ###

import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
R = 10**9 + 7
def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
s = inl()
t = inl()
dp = [ [0] * (m+1) for i in range(n) ]
dp[0][0] = 1 if s[0]==t[0] else 0
for i in range(1,n):
    dp[i][0] = dp[i-1][0] + (1 if s[i]==t[0] else 0)
for j in range(1,m):
    dp[0][j] = dp[0][j-1] + (1 if s[0]==t[j] else 0)

sh = defaultdict(list)
for i in range(1,n):
    sh[s[i]].append(i)

for j in range(1,m):
    x = 0
    acc = [0] * (n+1)
    for z in sh[t[j]]:  # s[z]==t[j]
        x = (x+dp[z-1][j-1]+1)%R  # z>0
        acc[z] = x
    for i in range(1,n):
        acc[i] = (acc[i-1] if acc[i]==0 else acc[i])

    for i in range(1,n):
        x = dp[i][j-1]
        #for z in sh[t[j]]:  # s[z]==t[j]
        #  if z<=i:
        #    x = (x+dp[z-1][j-1]+1)%R  # z>0
        x += acc[i]
        if t[j]==s[0]:
            x += 1
        dp[i][j] = x%R

if DBG:
    for i in range(n):
        print(dp[i])
print((dp[n-1][m-1]+1)%R)
### BUGGY CODE ###

N = int(input())
S = list(input())
cnt=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            A=[i,j,k]
            m=0
            for l in range(N):
                #print("i,j,k,l,m,cnt",i,j,k,l,m,cnt)
                if int(S[l]) == A[m]:
                    m += 1
                if m == 3:
                    cnt += 1
                    break

print(cnt)





### FIXED CODE ###

N = int(input())
S = input()
cnt=0
for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b=S.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            c=S.find(str(k),b+1)
            if c != -1:
                cnt+=1
            

print(cnt)
### BUGGY CODE ###

from itertools import accumulate
from heapq import heappush, heappop, heapify

def bisect(ng, ok, judge, eps=1):
    while abs(ng-ok) > eps:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N,M = map(int,input().split())
A = sorted(map(int,input().split()))
acc = [0]+list(accumulate(A))

def judge(p):
    j = N
    cnt = 0
    for al in A:
        while j > 0 and al+A[j-1] >= p:
            j -= 1
        cnt += N-j
    return cnt <= M

p = bisect(0, A[-1]*2+1, judge)

j = N
cnt = 0
res = 0
q = []
for al in A:
    while j > 0 and al+A[j-1] >= p:
        j -= 1
    cnt += N-j
    res += (N-j)*al + acc[-1]-acc[j]
    if j > 0:
        q.append((-(al+A[j-1]),al,j-1))

heapify(q)
for _ in range(M-cnt):
    p,al,j = heappop(q)
    res -= p
    if j > 0:
        heappush(q, (-(al+A[j-1]),al,j-1))

print(res)

### FIXED CODE ###

from itertools import accumulate

def bisect(ng, ok, judge, eps=1):
    while abs(ng-ok) > eps:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N,M = map(int,input().split())
A = sorted(map(int,input().split()))
acc = [0]+list(accumulate(A))

def judge(p):
    j = N
    cnt = 0
    for al in A:
        while j > 0 and al+A[j-1] >= p:
            j -= 1
        cnt += N-j
    return cnt <= M

p = bisect(0, A[-1]*2+1, judge)

j = N
cnt = 0
res = 0
nv = 0
max2 = lambda x,y: x if x > y else y
for al in A:
    while j > 0 and al+A[j-1] >= p:
        j -= 1
    cnt += N-j
    res += (N-j)*al + acc[-1]-acc[j]
    if j > 0:
        nv = max2(nv, al+A[j-1])

res += nv*(M-cnt)
print(res)
### BUGGY CODE ###

k, s = map(int, input().split(" "))

count = int(0)

for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            if s == i + j + l:
                count += 1
print(count)


### FIXED CODE ###

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

count = int(0)

for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <= k:
            count += 1
print(count)
### BUGGY CODE ###

from collections import defaultdict
# from sys import stdin
# input = stdin.readline


def main():
  # S = input()[-1:0:-1]
  S = input()[::-1]
  MOD = 2019

  dp = [0]*(len(S)+1)
  dp[0] = 0

  ten = 1
  for i, s in enumerate(S):
    dp[i] = (dp[i-1] + ten*int(s)) % MOD
    ten *= 10

  dic = [0]*2019
  sum_ = 0
  for sup in dp:
    dic[sup] += 1

  for v in dic:
    sum_ += v*(v-1)//2

  print(sum_)


if(__name__ == '__main__'):
  main()


### FIXED CODE ###

def main():
  # S = input()[-1:0:-1]
  S = input()[::-1]
  MOD = 2019

  # dp = [0]*(len(S)+1)
  # dp[0] = 0
  dic = [0]*2019
  dic[0] = 1

  ten = 1
  pre = 0
  for i, s in enumerate(S):
    # dp[i] = (dp[i-1] + ten*int(s)) % MOD
    pre = (pre + ten*int(s)) % MOD
    dic[pre] += 1
    ten *= 10
    ten %= MOD

  sum_ = 0
  # for sup in dp:
  #   dic[sup] += 1

  for v in dic:
    sum_ += v*(v-1)//2

  print(sum_)


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

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
MAX_RSESULT = 1000000000000000000

result = 1
for ai in a:
    result *= ai
if result <= MAX_RSESULT:
    print(result)
else:
    print(-1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
MAX_RSESULT = 1000000000000000000

result = 1
a.sort(reverse=True)

if a[-1]==0:
    result = 0
else:
    for ai in a:
        result *= ai
        if result > MAX_RSESULT:
            result = -1
            break
print(result)
### BUGGY CODE ###

n,a,b = map(int,input().split())
ans = []
while(len(ans) < n):
    for i in range(a):
        if(len(ans) >= n):
            break
        ans.append(1)
    for i in range(b):
        ans.append(0)
print(sum(ans))

### FIXED CODE ###

n,a,b = map(int,input().split())
print(a*(n//(a+b)) + min(n%(a+b),a))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
# 整数の入力
A, B, C= map(int, input().split())
# 出力
if A==B and B==C:
 if A%2 ==0 and B%2==0 and C%2==1:
  print(-1)
  sys.exit()
count=0
while True:
 if A%2 ==1 or B%2==1 or C%2==1:
  print(count)
  sys.exit()
 else:
  A_a=B/2+C/2
  B_a=A/2+C/2
  C_a=A/2+B/2
  A=A_a
  B=B_a
  C=C_a
  count+=1


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# 整数の入力
A, B, C= map(int, input().split())
# 出力
if A==B and B==C:
 if A%2 ==0 and B%2==0 and C%2==0:
  print(-1)
  sys.exit()
count=0
while True:
 if A%2 ==1 or B%2==1 or C%2==1:
  print(count)
  sys.exit()
 else:
  A_a=B/2+C/2
  B_a=A/2+C/2
  C_a=A/2+B/2
  A=A_a
  B=B_a
  C=C_a
  count+=1
### BUGGY CODE ###

# -*- coding: utf-8 -*-

T = 0
F = 2
C = 4

s = input()
q = int(input())

# query = [input().split() for l in range(q)]





# print(s,q,query)

cnt = 0

for i in range(q):
    query = input()

    # print(query[i])
    if query[T] == "1":
        cnt += 1
        continue

    # print(s)
    if cnt % 2 == 0:
        # print(query[i])
        if query[F] == "1":
            s = query[C] + s
            # print(s)
        else:
            s = s + query[C]

    else:
        # print(query[i])
        if query[F] == "1":
            # print(s)
            s = s + query[C]
        else:
            s = query[C] + s

if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###

# -*- coding: utf-8 -*-

T = 0
F = 2
C = 4

s = input()
q = int(input())

cnt = 0

front = ""
back = ""

for i in range(q):
    query = input()

    if query[T] == "1":
        cnt += 1
        continue

    # モード通常
    if cnt % 2 == 0:
        if query[F] == "1":
            front +=  query[C]
        else:
            back += query[C]

    # モード反転
    else:
        if query[F] == "1":
            back += query[C]
        else:
            front +=  query[C]


# print(cnt)
# print(front)
# print(s)
# print(back)

# moji = front+s+back

if cnt % 2 == 0:
    print(front[::-1]+s+back)
    pass
else:
    print(back[::-1]+s[::-1]+front)
    # print(s[::-1])
### BUGGY CODE ###

N,K,Q=map(int,input().split())
a = [int(input()) for i in range(Q)]
point=[K for i in range(N)]
for i in range(Q):
  for j in range(N):
    if not j==a[i]-1:
      point[j]=point[j]-1
re=[]
for j in range(N):
  if point[j]<=0:
    print("No")
  else:
    print("Yes")

### FIXED CODE ###

N,K,Q=map(int,input().split())
a = [int(input()) for i in range(Q)]
point=[0 for i in range(N)]
for i in range(Q):
  point[a[i]-1]=point[a[i]-1]+1
for j in range(N):
  if point[j]>=Q-K+1:
    print("Yes")
  else:
    print("No")