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); a=a.OrderBy(i=>i).ToArray(); int res = 0; for (int i = 0; i < n; i++) { int res2 = 1; for (int j = i+1; j < n; j++) { if (Math.Abs(a[i] - a[j]) <= 1) { res2++; } if (Math.Abs(a[i] - a[j]) > 1) break; } res = res < res2 ? res2 : res; } Console.WriteLine(res); } }