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]; var ok = new bool[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 }; ok[i] = true; } getAns(n, ps, ok); } static void getAns(int n, P[] ps, bool[] ok) { ps = ps.OrderBy(x => x.a).ToArray(); var count = 0; for (int i = 0; i < n; i++) { if (ok[ps[i].id]) { count++; if (ps[i].id != 0) ok[ps[i].id - 1] = false; } } Console.WriteLine(count); } }