import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); //int[] a = new int[n]; Hashtable a = new Hashtable<>(); for(int a_i=0; a_i < n; a_i++){ int cur = in.nextInt(); if(a.containsKey(cur)) a.put(cur, a.remove(cur) + 1); else a.put(cur, 1); } Enumeration keys = a.keys(); int maxSoFar = 0; while(keys.hasMoreElements()){ int cur = keys.nextElement(); Integer less = a.get(cur - 1); Integer more = a.get(cur + 1); if(less == null) less = 0; if(more == null) more = 0; maxSoFar = Math.max(maxSoFar, Math.max(less, more) + a.get(cur)); } System.out.println(maxSoFar); } }