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(); Integer[] a = new Integer[n]; for(int a_i=0; a_i < n; a_i++){ a[a_i] = in.nextInt(); } List as = Arrays.asList(a); System.out.println(as.stream().map(i -> takeForChoice(i, as)).max((x,y) -> x > y ? 1 : -1).get()); } public static int takeForChoice(int i, List is) { int cInf = 0; int cSup = 0; for(Integer in : is) { if(i==in) { cInf ++; cSup ++; } else if(i > in && i - in == 1) { cInf ++; } else if(in > i && in - i == 1) { cSup ++; } } return cInf > cSup ? cInf : cSup; } }