using System; using System.Linq; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int hit = n; for (int i = n - 1; 0 <= i; i--) { if (a[i] == hit) { hit--; } } Console.WriteLine(hit); } }