using System; using System.Collections.Generic; namespace MobProgramming { class JengaSort { private static List _ryoList = new List(); static void Main() { Int32 length = Int32.Parse(Console.ReadLine()); String[] s = Console.ReadLine().Split(' '); Initialize(s); Console.WriteLine(CountRyo(length)); } static void Initialize(String[] strArray) { foreach (var str in strArray) { _ryoList.Add(Int32.Parse(str)); } } static Int32 CountRyo(Int32 num) { if (_ryoList.IndexOf(num) > _ryoList.IndexOf(num - 1)) { var result = CountRyo(num - 1); return result; } return num - 1; } } }