N=int(input())
A = list(map(int,input().split()))
cc =0#株の数
cash =1000
bd =[0]*N#買う日
sd =[0]*N
for i in range(N):
  j =0
  while A[i] >= A[i+j]:
    bd[i] =i
    bd[i+j]=-1
    j = j+1
    if i+j >N-1:
      break
  k =0
  while A[i] <= A[i+k]:
    sd[i] =i+1
    sd[i+k]=-1
    k = k+1
    if i+k >N-1:
      break
if A[N-1] >A[N-2]:
  bd[N-1] = N
if A[N-1] < A[N-2]:
  sd[N-1] = N
sf = sorted(bd)[N-1]
for i in range(N):
  if bd[i]>0:
    if cc >0:
      cash =cash + cc*A[i]
      cc = 0
      print(cash)
  if sd[i]>0:
    cc = cash // A[i]
    cash = cash % A[i]

print(cash)
print(bd)
print(sd)