n=gets a=gets.split.map &:to_i b=[] u=[] a.map{|v|i=b.index{|k|k>=v};j=i ?i: b.size;u+=(-b.size...-j).to_a;b.insert(j,v);} p u.size for i in u;puts [-i-1,-i]*' ';end