using System.Linq; using System; public class P { public int a { get; set; } public int id { get; set; } } public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var ps = new P[n]; string[] line = Console.ReadLine().Trim().Split(' '); for (int i = 0; i < n; i++) { ps[i] = new P { a = int.Parse(line[i]), id = i }; } getAns(n, ps); } static void getAns(int n, P[] ps) { var ng = new bool[n]; var count = 0; foreach (var x in ps.OrderBy(y => y.a)) if (!ng[x.id]) { count++; if (x.id != 0) ng[x.id - 1] = true; } Console.WriteLine(count); } }