n=gets.to_i pq_base=[nil] gets.split.each.with_index(1){|j,i| a=j.to_i<<8 i/=2 while i>1 && apq[c+1] break if a<=pq[i]=pq[c] i=c end pq[i]=a i=n i>>=1 while i>1 && d>1] x=(pq[i]=d)&0xFF max=x if maxmax } p min