using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Application { class MainClass { public static void Main (string[] args) { readInt (); var A = readInts (' '); var s = new Searcher (); var r = 0; var sortedA = A.OrderBy(ss => ss).Distinct().ToArray(); while (r < sortedA.Length) { r += s.LonguestSeq (sortedA, r); } writeLine(s.Longuest); } public class Searcher { public int Longuest = 0; public int LonguestSeq (int[] A, int l) { var i = l + 1; for (; i < A.Count (); i++){ if (A[i - 1] != A[i] - 1) break; } var len = i - l; this.Longuest = Math.Max(len, this.Longuest); return len; } } static void writeLine (object o) { System.Console.WriteLine (o.ToString ()); } static string readItem () { return readItems (' ') [0]; } static String[] readItems (char c) { return System.Console.ReadLine ().Split (c); } static int readInt () { return readInts (' ') [0]; } static int[] readInts (char c) { return readItems (c).Select (x => int.Parse (x)).ToArray (); } } }