using System; using System.Linq; namespace GengaSort { class Program { static void Main(string[] args) { int[] Xn = new int[int.Parse( Console.ReadLine() )]; int[] An = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int ix = 0, count =0; while(ix > -1) { ix = -1; for (int i = 0; i < An.Length - 1; i++) { if ( An[i] > An[i + 1] && ( ix == -1 || An[ix] < An[i + 1])) ix = i + 1; } if (ix > -1) { count++; for (int i = 0; i < An.Length; i++) { if (i == ix) { Xn[0] = An[i]; } else if (i < ix) { Xn[i + 1] = An[i]; } else { Xn[i] = An[i]; } } Array.Copy(Xn, An, Xn.Length); } } Console.WriteLine(count); } } }