import java.util.*; import java.math.*; class picking_numbers { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList al = new ArrayList(n); int i, j; for(i = 0; i < n; ++i) al.add(sc.nextInt()); Collections.sort(al); int max = 0, count = 0; for(i = 0; i < n - 1; ++i) { count = 1; for(j = i+1; j < n; ++j) { if(i != j) { if(Math.abs(al.get(i) - al.get(j)) <= 1) ++count; else break; } } max = Integer.max(max, count); } System.out.println(max); } }