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) throws NumberFormatException, IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] input = br.readLine().split(" "); int[] a = new int[n]; for(int i = 0 ; i < a.length ; i++){ a[i] = Integer.parseInt(input[i]); } Arrays.sort(a); int maxCount = 1; for(int i = 0 ; i < a.length -1 ; i++){ int tempCount = 1; for(int j = i+1 ; j < a.length ; j++){ if(a[j] == a[i] || a[j] == a[i] + 1 || a[j] == a[i] - 1){ tempCount++; } else { break; } } maxCount = Math.max(maxCount, tempCount); } System.out.println(maxCount); } }