k=gets.to_i;a=gets.split.map(&:to_i) (k-1).downto(0){|i| k-=1 if a[i]==k } p k