using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] a_temp = Console.ReadLine().Split(' '); int[] a = Array.ConvertAll(a_temp, Int32.Parse); Console.WriteLine(FindMaxDiff(a)); } static int FindMaxDiff(int[] a) { int diffMax = 0; List diff = new List(); Array.Sort(a); diff.Add(a[0]); for (int i = 1; i < a.Length; i++) { if ((a[i] == diff.First()) || (a[i] == diff.First() + 1)) { diff.Add(a[i]); } else { if (diff.Count > diffMax) diffMax = diff.Count; diff.Clear(); diff.Add(a[i]); } } if (diff.Count > diffMax) diffMax = diff.Count; return diffMax; } }