from numpy import * N=int(input()) A=int64(input().split()+[1]) s=ones((20,N+1),int64) s[0]=A for n in range(19): d=1<