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]; //ArrayList al = new ArrayList<>(); //int lowest = Integer.MAX_VALUE; //int highest = Integer.MIN_VALUE; for(int a_i=0; a_i < n; a_i++){ a[a_i] = in.nextInt(); } int largest = 1; for(int i = 0; i < a.length; i++){ int counter = 0; int[] al = new int[2]; for(int ix = 0; ix < a.length; ix++){ //if lower, check a[ix] if it's higher than a[i] //reset the current if a[i] difference from curr is greater than 0 if(Math.abs(a[ix] - a[i]) <= 1){ //keep counter of numbers larger and smaller if(a[ix] <= a[i]){ al[0]++; } else { al[1]++; } } } counter = Math.max(al[0], al[1]); largest = Math.max(largest, counter); } System.out.println(largest); } }