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]; for(int a_i=0; a_i < n; a_i++){ a[a_i] = in.nextInt(); } int max = 0; for(int i = 0; i < n; i++) { int element = a[i]; int element2 = a[i]; int count = 0; int c = 0; for(int j = 0; j < n; j++) { if(i == j) { continue; } if(c == 1) { if(a[j] == element || a[j] == element2) { count++; continue; } } if(Math.abs(a[i] - a[j]) == 1 && c == 0) { c = 1; count++; element2 = a[j]; } if(Math.abs(a[i] - a[j]) == 0 && c == 0) { count++; } } if(count != 0 && count + 1 > max) { max = count + 1; } } System.out.println(max); } }