n,*a=$<.read.split.map &:to_i n-=1if n==a.pop while a.size>0 p n