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); Array.Sort(a); var answer = 0; var tempMax = 0; int? startNum = null; for (int i = 1; i < n; i++){ if (a[i] - a[i - 1] <= 1){ if (startNum != null){ if (a[i] - startNum <= 1){ tempMax++; } else{ if (answer < tempMax){ answer = tempMax; } tempMax = 0; startNum = null; } } else{ startNum = a[i - 1]; tempMax++; } } if (a[i] - a[i - 1] > 1){ if (tempMax > answer){ answer = tempMax; } tempMax = 0; startNum = null; } } if (tempMax > answer){ answer = tempMax; } Console.WriteLine(answer+1); } }