/** * Created by distro on 13/12/16. */ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Prog1 { public static void main(String args[]) throws IOException { long t1 = System.currentTimeMillis(); SolverProg1 ob = new SolverProg1(); ob.Solve(); long t2 = System.currentTimeMillis(); System.err.println("Time = " + (t2 - t1) * 1.0 / 1000 + " seconds"); } } class SolverProg1 { BufferedReader br; private String readString() throws IOException { return br.readLine(); } private int readInt() throws IOException { return Integer.parseInt(br.readLine()); } private long readLong() throws IOException { return Long.parseLong(br.readLine()); } private double readDouble() throws IOException { return Double.parseDouble(br.readLine()); } private int[] readIntSequence() throws IOException { String temp[] = br.readLine().trim().split(" "); int arrtemp[] = new int[temp.length]; for (int i = 0; i < temp.length; i++) { arrtemp[i] = Integer.parseInt(temp[i]); } return arrtemp; } private void setInputRedirect() throws FileNotFoundException { String InputBasePath = "Input/"; String InputFile = "Input" + "Prog1" + ".txt"; System.setIn(new FileInputStream(InputBasePath + InputFile)); } public void Solve() throws IOException { //setInputRedirect(); br = new BufferedReader(new InputStreamReader(System.in)); // Solution Goes Here int N = readInt(); int maxval = -1; int[] arr = readIntSequence(); Arrays.sort(arr); for (int i = 0; i < N; i++) { int num = arr[i]; int count = 1; for (int j = i + 1; j < N; j++) { if (Math.abs(arr[j] - num) <= 1) { count++; } else { break; } } if (count > maxval) { maxval = count; } } System.out.println(maxval); // Solution Ends Here } }