N = int(eval(input()))

L = [0 for i in range(5)]

for i in range(5):

    L[i] = int(eval(input()))

    

time = [0 for i in range(5)]

time[0] = (N-1)//L[0] + 1

for i in range(4):

    if L[i] <= L[i+1]:

        time[i+1] = time[i]

    else:

        time[i+1] = (N-1)//L[i+1] + 1

        

ans = max(time) + 4

        

print(ans)
N = int(eval(input()))

L = [int(eval(input())) for _ in range(5)]



n = min(L)

ans = (N+n-1) // n + 4

print(ans)
N = int(eval(input()))
L = [0 for i in range(5)]
for i in range(5):
    L[i] = int(eval(input()))
time = [0 for i in range(5)]
time[0] = (N - 1) // L[0] + 1
for i in range(4):
    if L[i] <= L[i + 1]:
        time[i + 1] = time[i]
    else:
        time[i + 1] = (N - 1) // L[i + 1] + 1
ans = max(time) + 4
print(ans)

N = int(eval(input()))
L = [int(eval(input())) for _ in range(5)]
n = min(L)
ans = (N + n - 1) // n + 4
print(ans)

-L = [0 for i in range(5)] -for i in range(5): -    L[i] = int(eval(input())) -time = [0 for i in range(5)] -time[0] = (N - 1) // L[0] + 1 -for i in range(4): -    if L[i] <= L[i + 1]: -        time[i + 1] = time[i] -    else: -        time[i + 1] = (N - 1) // L[i + 1] + 1 -ans = max(time) + 4 +L = [int(eval(input())) for _ in range(5)] +n = min(L) +ans = (N + n - 1) // n + 4