import java.util.*; public class Solution { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int size = new Integer(sc.nextLine()); int[] arr = new int[size]; String line = sc.nextLine(); String[] el = line.split(" "); for (int i = 0; i < size; i++) { arr[i] = new Integer(el[i]); } minDifference(arr); } private static void minDifference(int[] arr) throws Exception { int maxLength = 0; for (int i = 0; i < arr.length; i++) { int count1 = 1, count2 = 1; for (int j = 0; j < arr.length; j++) { if (i == j) continue; if (arr[i]-arr[j] == 0 || arr[i]-arr[j] == 1) count1++; if (arr[i]-arr[j] == 0 || arr[i]-arr[j] == -1) count2++; } int maxCount = Math.max(count1, count2); if (maxCount > maxLength) maxLength = maxCount; } System.out.println(maxLength); } }