Harryxun/stf_run huggingface dataset:
N = ii()
A = li()
ans = 1
for num in A:
    if ans < 10**18 / num:
        #print(ans, 10**18 / num)
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
n,m=map(int,input().split())
ac=[0 for _ in range(n)]
wt=[0 for _ in range(n)]
pen=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        ac.append(int(p))
        pen += wt[int(p)]
    else:
        if int(p) in ac:
            pass
        else:
            wt[int(p)] += 1
            
t_ac=set(ac))
print(len(t_ac),pen)







### FIXED CODE ###

n,m=map(int,input().split())
AC=[0 for _ in range(n)]
WA=[0 for _ in range(n)]
pen=0
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if AC[p-1]==0:
            AC[p-1]=1
            pen += WA[p-1]
        else:
            pass
    else:
        if AC[p-1]==0:
            WA[p-1] +=1
        else:
            pass
print(AC.count(1),pen)
n = int(input())
a = [int(input()) for _ in range(n)]

s=''
for i,x in enumerate(a):
  if x != 0:
    s += str(i+1)*x
  else:
    s += '*'
s += '*'

ans=0
cnt=0
for c in s:
  if c != '*':
    cnt += 1
  else:
    ans += cnt // 2
    cnt=0
  
    
print(ans)


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
cnt = 0
for x in a:
  if x != 0:
    cnt += x
  else:
    ans += cnt // 2
    cnt = 0

ans += cnt // 2

print(ans)
N, K = map(int, open(0).read().split())
a = N % K
print(min(K - b, b))


### FIXED CODE ###

N, K = map(int, open(0).read().split())
a = N % K
print(min(K - a, a))
zS=input()
T=input()
ls=len(S)
lt=len(T)

ans='UNRESTORABLE'

if ls<lt:
    print(ans)
    exit()
for i in range(ls-lt,-1,-1):
    c=0
    for j in range(lt):
        if T[j]==S[i+j] or S[i+j]=='?':
            continue
        else:
            c=1
            break
    if c==0:
        ans=S.replace('?','a')
        ans=ans[:i] + T + ans[i+lt+1:]
        break
print(ans)


### FIXED CODE ###

s_prime=list(input())
t=list(input())
ls=len(s_prime)
lt=len(t)
s_prime.reverse()
t.reverse()


if lt>ls:
    print('UNRESTORABLE')
else:
    def check(t,s):
        l=len(t)
        c=0
        for i in range(l):
            if s[i]!='?' and s[i]!=t[i]:
                c=1
        return True if c==0 else False
    c=0            
    for i in range(ls-lt+1):
        print()
        if check(t,s_prime[i:i+lt])==1:
            t_in=s_prime[:i]+t+s_prime[i+lt:] 
            for k in range(ls):
                if t_in[k]=='?':
                    t_in[k]='a'
            t_in.reverse()   
            print(''.join(t_in))
            c=1
            break
    print('UNRESTORABLE') if c==0 else exit()
n,q=map(int,input().split())
s=input()
list_ac=[]
for i in range(0,len(s)):
    if s[i]=='A':
        place=i
        state=1
    elif s[i]=='C':
        if state==1:
            list_ac.append(place)
        state=0
    else:
        state=0      
for i in range(0,q):
    l,r=map(int,input().split())
    count=0
    for j in list_ac:
        if l-1<=j<=r-2:
            count=count+1
        elif j>r-2:
            break
    print(count)
        
    


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
list_ac=[0]
number=0
for i in range(0,n):
    if s[i:i+2]=='AC':
        number=number+1
        list_ac.append(number)
    else:
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])
import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())
X, Y = [0] * N, [0] * N
g = [[] for _ in range(N)]

for i in range(M):
    X[i], Y[i] = map(int, input().split())

    X[i] -= 1
    Y[i] -= 1
    g[X[i]].append(Y[i])
    g[Y[i]].append(X[i])


def bfs(x, y):
    visited = [False] * N
    q = queue.Queue()
    for nx in g[x]:
        if nx == y:
            continue
        q.put(nx)

    visited[x] = True

    while not q.empty():
        cur = q.get()
        if cur == y:
            return True

        visited[cur] = True
        for nx in g[cur]:
            if visited[nx]:
                continue
            q.put(nx)

    return False

cnt = 0
for i in range(M):
    if not bfs(X[i], Y[i]):
        cnt += 1

print(cnt)

### FIXED CODE ###

import collections
import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())
X, Y = [0] * M, [0] * M
g = [[] for _ in range(N)]

for i in range(M):
    X[i], Y[i] = map(int, input().split())

    X[i] -= 1
    Y[i] -= 1
    g[X[i]].append(Y[i])
    g[Y[i]].append(X[i])


def bfs(x, y):
    visited = [False] * N
    q = queue.Queue()
    for nx in g[x]:
        if nx == y:
            continue
        q.put(nx)
        visited[nx] = True

    visited[x] = True

    while not q.empty():
        cur = q.get()
        if cur == y:
            return True

        for nx in g[cur]:
            if visited[nx]:
                continue
            q.put(nx)
            visited[nx] = True

    return False


cnt = 0
for i in range(M):
    if not bfs(X[i], Y[i]):
        cnt += 1

print(cnt)
A, B = map(int, input().split())
D = []
E = []
total = A
for i in range(B):
    C = int(input())
    D = map(int, input().split())
    E.append(list(D))
for i in range(1, A+1):
  if str(i) in str(E):
    total = total - 1
print(total)

### FIXED CODE ###

I = input()
print("ABC" if I == "ARC" else "ARC")
a,b,x,y,s,m = map(int,input().split())

#a,b,x,y,s,m = (1,2,1,2,100,1000)
a *= 100
b *= 100

#入れられる水の候補
waterlist=[]
amax = int(m/a)
for i in range(amax+1):
  bmax = int((m-a*i)/b)
  for j in range(bmax+1):
    waterlist.append(a*i + b*j)
waterlist = set(waterlist)

#砂糖の組み合わせから最大を
def makesatolist(maxsato,x,y):
  satolist = []
  xmax = int(maxsato/x)
  for i in range(xmax+1):
    ymax  = int((maxsato-x*i)/y)
    for j in range(ymax+1):
      satolist.append(x*i + y*j)
  return max(satolist)
  
nownodo = 0
ans = []
for i in waterlist:
  if i == 0:
    continue
 
  # iグラムの水に何グラムの砂糖まで解ける？
  maxsato = i * s/100
  if i + maxsato > m:
    maxsato = m - i

  sato = makesatolist(maxsato,x,y)
  satowater = i + sato
  nodo = sato / satowater
  if nodo > nownodo:
    nownodo = nodo
    ans = [satowater,sato]

print(ans[0]," ",ans[1])

### FIXED CODE ###

a,b,x,y,s,m = map(int,input().split())

#a,b,x,y,s,m = (1,2,1,2,100,1000)
a *= 100
b *= 100

#入れられる水の候補
waterlist=[]
amax = int(m/a)
for i in range(amax+1):
  bmax = int((m-a*i)/b)
  for j in range(bmax+1):
    water = a*i + b*j
    if water:
      waterlist.append(a*i + b*j)
waterlist = set(waterlist)

#砂糖の組み合わせから最大を
def makesatolist(maxsato,x,y):
  satolist = []
  xmax = int(maxsato/x)
  for i in range(xmax+1):
    ymax  = int((maxsato-x*i)/y)
    for j in range(ymax+1):
      satolist.append(x*i + y*j)
  return max(satolist)
  
nownodo = 0
ans = [0] * 2
for i in waterlist:
 
  # iグラムの水に何グラムの砂糖まで解ける？
  maxsato = i * s/100
  if i + maxsato > m:
    maxsato = m - i

  sato = makesatolist(maxsato,x,y)
  satowater = i + sato
  nodo = sato / satowater
  if nodo >= nownodo:
    nownodo = nodo
    ans = [satowater,sato]

print(ans[0]," ",ans[1])
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u,v=u-1,v-1
    G[u].append((v,w))
    G[v].append((u,w))
res=[-1]*N
def dfs(v,p,c):
    res[v]=c
    for nv,w in G[v]:
        if res[nv]>=0:
            continue
        dfs(nv,v,(c+w)%2)
        """
        if w&1:
            dfs(nv,v,1-c)
        else:
            dfs(nv,v,c)
        """
dfs(0,-1,0)
for i in res:
    print(i)


### FIXED CODE ###

N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u,v=u-1,v-1
    G[u].append((v,w))
    G[v].append((u,w))
reached=[0]*N
stack=[0]
reached[0]=[1]
res=[-1]*N
res[0]=0
while(stack):
    v=stack.pop()
    for nv,w in G[v]:
        if reached[nv]:
            continue
        if w & 1:
            res[nv]=1-res[v]
        else:
            res[nv]=res[v]
        stack.append(nv)
        reached[nv]=1
for i in res:
    print(i)
from collections import deque

S = str(input())
T = str(input())

print(T, S, sep='')


### FIXED CODE ###


S, T = map(str,input().split())
print(T, S, sep='')
import sys
cnt = 1

while 1:
	num=sys.stdin.readline().strip()
	if num = "0":
		break
	print('Case {0}: {1}'.format(cnt, num))
	cnt+=1

### FIXED CODE ###

import sys
cnt = 1

while 1:
  num=sys.stdin.readline().strip()
  if num == "0":
    break
  print('Case {0}: {1}'.format(cnt, num))
  cnt+=1
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  print((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))

### FIXED CODE ###

n, k = map(int, input().split())
import math
mod = (10**9) +7
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    result = (kai(k-1)*kai(n-k+1))//(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))
    result2 = result % mod
    print(result2)
  else:
    print(0)
def price(target, item, recipe):
    ret = []
    
    if target in recipe:
        ret.append(sum(price(r,item, recipe) for r in recipe[target]))
    if target in item:
        ret.append(item[target])

    return min(ret)

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    item = [f.readline().split() for _ in range(n)]
    item = {name:int(price) for name, price in item}
    recipe = [f.readline().split() for _ in range(int(f.readline()))]
    recipe = {r[0]:r[2:] for r in recipe}
    print(price(f.readline().strip(), item, recipe))

### FIXED CODE ###

def price(target, item, recipe):
    ret = []
    
    if target in recipe:
        ret.append(sum(price(r,item, recipe) for r in recipe[target]))
    if target in item:
        ret.append(item[target])
    if len(ret) == 0:
        return 0

    return min(ret)

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    item = [f.readline().split() for _ in range(n)]
    item = {name:int(price) for name, price in item}
    recipe = [f.readline().strip().split() for _ in range(int(f.readline()))]
    recipe = {r[0]:r[2:] for r in recipe}
    print(price(f.readline().strip(), item, recipe))
n,h,w=map(int,open(0).read().split);print((n-h+1)*(n-w+1))

### FIXED CODE ###

n,h,w=map(int,open(0).read().split());print((n-h+1)*(n-w+1))
for i in range(10000):
    H,W=input().split())
    s = ""
    for j in range(int(W))
        s = s + "#"
    for k in range(int(H)):
        print(s)
    print("")


### FIXED CODE ###

for i in range(10000):
    H,W=input().split()
    if H=="0" and W=="0":
        break
    s = ""
    for j in range(int(W)):
        s = s + "#"
    for k in range(int(H)):
        print(s)
    print("")
A=[int(i) for i input().split()]
A.sort()
print(A[2]-A[0])

### FIXED CODE ###

A=[int(i) for i in input().split()]
A.sort()
print(A[2]-A[0])
n,m=list(map(input().split()))
print(m.append(n))

### FIXED CODE ###

n,m=input().split()
print(m+n)
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[None]*3 for _ in range(n)]
dp[0] = abc[0]
K = [[1, 2], [0, 2], [0, 1]]
for i in range(1, n):
    abci = abc[i]
    for j in range(3):
        for k in K[j]:
            dp[i][j] = max(dp[i-1][k[0]]+abci[j], dp[i-1][k[1]]+abci[j])
print(max(dp[-1]))

### FIXED CODE ###

n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[None]*3 for _ in range(n)]
dp[0] = abc[0]
m = [[0, [1, 2]], [1, [0, 2]], [2, [0, 1]]]
for i in range(1, n):
    abci = abc[i]
    for j, k in m:
        dp[i][j] = max(dp[i-1][k[0]]+abci[j], dp[i-1][k[1]]+abci[j])
print(max(dp[-1]))
import math

l = [input() for x in range(4)]
dist = math.sqrt((l[0] - l[2])**2 + (l[1] - l[3])**2)
print dist

### FIXED CODE ###

import math

l = map(float, raw_input().split())
dist = math.sqrt((l[0] - l[2])**2 + (l[1] - l[3])**2)
print dist
import sys
while True:
    S = sys.stdin.readlines().lower()
    a = [0 for i in range(26)]
    for c in S:
        if ord(c) >= 97\
        and ord(c) <= 122:
            i = ord(c) - 97
            a[i] += 1

    for i in range(26):
        print("{0} : {1}".format(chr(i + 97), a[i]))

### FIXED CODE ###

import sys
cnts = {}
for line in sys.stdin:
    for c in list(line.lower()): cnts[c] = cnts.get(c,0) + 1
  
for c in range(ord('a'),ord('z')+1): print(chr(c),':',cnts.get(chr(c),0))
data = raw_input()

n,m = map(int,data.split(" "))

data = []

for x in range(n):
  data.append(raw_input())

temp = []

for x in range(m):
  temp.append(raw_input())

for x in range(n):
  for y in range(n):
    if temp[0] == data[x][y:y+m]:
      flag = 1
      pos = y
      for xx in range(x+1,x+m):
        if temp[xx - x] != data[xx][pos:pos+m]:
          flag = 0
          break
      if flag == 1:
        print "Yes"
        exit(0)

print "No"

### FIXED CODE ###

data = raw_input()

n,m = map(int,data.split(" "))

data = []

for x in range(n):
  data.append(raw_input())

temp = []

for x in range(m):
  temp.append(raw_input())

for x in range(n-m+1):
  for y in range(n-m+1):
    if temp[0] == data[x][y:y+m]:
      flag = 1
      pos = y
      for xx in range(x+1,x+m):
        if temp[xx - x] != data[xx][pos:pos+m]:
          flag = 0
          break
      if flag == 1:
        print "Yes"
        exit(0)

print "No"
a=input()
b=input()
print a*b ,a*2+b*2

### FIXED CODE ###

h,w=map(int,raw_input().split())
print("%d %d"%(h*w,h*2+w*2))
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
for i in range(K):
  H[i]=0
count = sum(H)
print(count)

### FIXED CODE ###

N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
if N>K:
  for i in range(K):
    H[i]=0
  count = sum(H)
  print(count)
else:
  print(0)
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)

def main():
    N, M = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(M)]
    ans = [0 for _ in range(N)]
    if N > 1:
        ans[0] = 1
    for i, s in enumerate(S):
        if s[0] == 1 and s[1] == 0:
            if N > 1:
                print(-1)
                return
        for i2, s2 in enumerate(S):
            if i == i2:
                continue
            if s[0] == s2[0]:
                if s[1] != s2[1]:
                    print(-1)
                    return
        ANS[s[0] - 1] = s[1]
    ans = int(''.join([str(n) for n in ANS]))
    print(ans)
    return
 
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N, M = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(M)]
    ans = [0 for _ in range(N)]
    if N > 1:
        ans[0] = 1
    for i, s in enumerate(S):
        if s[0] == 1 and s[1] == 0:
            if N > 1:
                print(-1)
                return
        for i2, s2 in enumerate(S):
            if i == i2:
                continue
            if s[0] == s2[0]:
                if s[1] != s2[1]:
                    print(-1)
                    return
        ans[s[0] - 1] = s[1]
    ans = int(''.join([str(n) for n in ans]))
    print(ans)
    return


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

if (int(A[0])+int(A[2])+int(A[4]))>=22:
    print('burst')
else:
    print('win')



### FIXED CODE ###

a,b,c=(int(x) for x in input().split())

if (a+b+c)>=22:
    print('bust')
else:
    print('win')
N=int(input())
a=list(map(1/int,input().split()))
print(1/sum(a))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
for i in range(0,N):
	a[i]=1/a[i]
print(1/sum(a))
import numpy as np

N = int(input())
S = input()

ans = [np.zeros(N), np.zeros(N)]

for i in range(N):
    if S[i] == "#":
        ans[0][i:] += 1
    else:
        ans[1][:i+1] += 1

print(min(ans[0][N-1], ans[1][0], np.min(ans[0][1:]+ans[1][:N-1])))

### FIXED CODE ###

N = int(input())
S = input()

ans =  S.count(".")
l = [0, ans]
for i in range(N):
    if S[i] == "#":
        l[0] += 1
    else:
         l[1] -= 1
    
    if ans > sum(l):
        ans = sum(l)
print(ans)
a = input()
b = input()

if a * b % 2 == 0:
	print('even')
else:
	print('odd')


### FIXED CODE ###

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

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')
n = int(input())
list_x = list(map(int, input().split()))

#iが座標の位置

list_ans = []

for i in range(min(list_x), max(list_x)):
    
    #計算する
    ans = 0
    for j in list_x:
        ans += (i-j)**2

    list_ans.append(ans)

print(min(list_ans))

### FIXED CODE ###

n = int(input())
list_x = list(map(int, input().split()))
 
#iが座標の位置
 
list_ans = []
 
for i in range(min(list_x), max(list_x)+1):
    
    #計算する
    ans = 0
    for j in list_x:
        ans += (i-j)**2
 
    list_ans.append(ans)
  
print(min(list_ans))
NK = list(map(int, input().split(' ')))
N = NK[0]
K = NK[1]
A = list(map(int, input().split(' ')))

score = A[0]
for i in range(1, K):
    score = score * A[i]
score_list = [score]

for i in range(K, N)
    score = score * A[i] / A[i-K]
    score_list.append(score)

for i in range(len(score_list) - 1):
    if (score_list[i] < score_list[i+1]):
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

NK = list(map(int, input().split(' ')))
N = NK[0]
K = NK[1]
A = list(map(int, input().split(' ')))

for i in range(K, N):
    if (A[i-K] < A[i]):
        print('Yes')
    else:
        print('No')
n = int(input())
A = list(map(int,input().split()))
A = Counter(A).most_common()
ans = 0

for i,j in sorted(A,reverse=True):
  if j >=4 and ans ==0:
    ans = i*i
    break
  elif j >= 2 and ans == 0:
    ans = i
  elif j >= 2:
    ans *= i
    break
print(ans)
print(sorted(A,reverse=True))

### FIXED CODE ###

from collections import Counter

n = int(input())
A = list(map(int,input().split()))
A = Counter(A).most_common()
ans = 0

for i,j in sorted(A,reverse=True):
  if j >=4 and ans ==0:
    ans = i*i
    break
  elif j >= 2 and ans == 0:
    ans = i
  elif j >= 2:
    ans *= i
    break
print(ans)
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()


### FIXED CODE ###

import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7

def main():
    N=int(input())
    dp=[0, 0, 0]
    for _ in range(N):
        a,b,c=map(int, input().split())
        ndp=[0, 0, 0]
        ndp[0]=max(dp[1], dp[2])+a
        ndp[1]=max(dp[2], dp[0])+b
        ndp[2]=max(dp[0], dp[1])+c
        dp=ndp
    print(max(dp))

if __name__=='__main__':
    main()
N = int(input())
monster = list(map(int, input().split()))
if 1 in monster:
  print(1)
else:
  monster.sort()
  min1, min2 = monster[0], monster[1]
  while min1 >= 0 and min2 > 0:
    if min1 < min2:
      min2 = min2 % min1
    else:
      min1 = min1 % min2
  print(max(min1, min2))

### FIXED CODE ###

from functools import reduce
from fractions import gcd
N = int(input())
monster = list(map(int, input().split()))
print(reduce(gcd, monster))
x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
Pl = 0
Ql = 0
Rb = 0

P.sort(reverse = True)
Q.sort(reverse = True)
R.sort(reverse = True)

P = P[0:x]
Q = Q[0:y]

while P[-1 - Pl] < R[0 + Rb] or Q[-1 - Ql] < R[0 + Rb]:
    if Q[-1 - Ql] >= P[-1 - Pl]:
        P[-1 - Pl] = R[0 + Rb]
        Pl = Pl + 1
    else:
        Q[-1 - Ql] = R[0 + Rb]
        Ql = Ql + 1

    Rb = Rb + 1
    if Rb == len(R):
        break

print(sum(P) + sum(Q))

### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
Pl = 0
Ql = 0
Rb = 0

P.sort(reverse = True)
Q.sort(reverse = True)
R.sort(reverse = True)

P = P[0:x]
Q = Q[0:y]

#while (P[-1 - Pl] < R[0 + Rb] or Q[-1 - Ql] < R[0 + Rb]):
#while (P[-1 - Pl] < R[0 + Rb] or Q[-1 - Ql] < R[0 + Rb]) and (Pl != len(P) or Ql != len(Q)):
while Pl != len(P) or Ql != len(Q):
    if Pl == len(P):
        if Q[-1 - Ql] < R[0 + Rb]:
            Q[-1 - Ql] = R[0 + Rb]
            Ql = Ql + 1
        else:
            break
    elif Ql == len(Q):
        if P[-1 - Pl] < R[0 + Rb]:
            P[-1 - Pl] = R[0 + Rb]
            Pl = Pl + 1
        else:
            break

    elif Q[-1 - Ql] >= P[-1 - Pl] and P[-1 - Pl] < R[0 + Rb]:
        P[-1 - Pl] = R[0 + Rb]
        Pl = Pl + 1
    elif P[-1 - Pl] > Q[-1 - Ql] and Q[-1 - Ql] < R[0 + Rb]:
        Q[-1 - Ql] = R[0 + Rb]
        Ql = Ql + 1

    else:
        break

    Rb = Rb + 1
    if Rb == len(R):
        break

print(sum(P) + sum(Q))
s = input()
a = int(s[:2]) > 13 or int(s[:2])=0
b = int(s[2:]) > 13 or int(s[2:])=0
if a and b:
  print("NA")
elif not a and not b:
  print("AMBIGUOUS")
elif not a and b:
  print("MMYY")
else:
  print("YYMM")
      

### FIXED CODE ###

s = input()
a = int(s[:2])
b = int(s[2:])
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")
import bisect

N,M,V,P = map(int, input().split())
A = [int(a) for a in input().split()]

cnt = 0
A.sort()
S = [0]*(N+1)
for i in range(N):
    S[i+1] = S[i]+A[i]
    
if V <= P:
    for i in range(N-P):
        if A[i]+M < A[N-P]:
            cnt += 1
        else:
            break
else:
    for i in range(N-P):
        if i+P >= V:
            if A[i]+M < A[N-P]:
                cnt += 1
            else:
                break
        else:
            num = M*V-M*(i+P)#さばかないといけない数
            j = bisect.bisect_left(A, A[i]+M)
            if A[j] == A[i]+M:
                j -= 1
            j = min(j, N-P)
            
            t = (j-i)*(A[i]+M)-(S[j+1]-S[i+1])#空いてる数
            t -= t%(V-P-i)
            if num > t:
                cnt += 1
            else:
                break
                
print(N-cnt)

### FIXED CODE ###

N,M,V,P = map(int, input().split())
A = [int(a) for a in input().split()]

A.sort(reverse=True)

S = [0]*N
t = 0
for i in range(N):
    t += A[i]
    S[i] = t

s = M*(N-V)
l = P
r = N
if P == 1:
    a = 0
else:
    a = S[P-2]
while l < r:
    m = (r-l)//2 + l
    if A[P-1]-M > A[m]:
        r = m
        continue
    if S[m-1]-a-(m-P+1)*A[m] > s:
        r = m
        continue
    l = m+1
    
print(l)