n = gets.to_i a = gets.split.map(&:to_i) x = a[0] c = 1 1.upto(n - 1){|i| if a[i] == x + 1 x = a[i] c += 1 elsif a[i] > x + 1 x = a[i] c = 1 end } p n - c