import java.util.*; public class Exercise38{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int num = sc.nextInt(); ArrayList array = new ArrayList(); for (int n = 0; n < num; n++){ array.add(sc.nextInt()); } int count = 0; int index = 1; while (index < array.size()){ if (array.get(index) - array.get(index - 1) > 1){ count++; } if (array.get(index - 1) > array.get(index)){ count++; array.remove(index); continue; } index++; } System.out.println(count); } }