import java.util.*; public class Exercises1 { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); int num = sc.nextInt(); int[] array = new int[num]; for (int n = 0; n < num; n++){ array[n] = sc.nextInt(); } for (int i = array.length - 1; i >= 0; i--){ if (array[i] == num){ num--; } } System.out.println(num); } }