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(); ArrayList list = new ArrayList(); HashMap count = new HashMap(); for(int a_i=0; a_i < n; a_i++){ int x = in.nextInt(); list.add(x); if(count.containsKey(x)) { count.put(x,count.get(x)+1); } else { count.put(x,1); } } Collections.sort(list); int ans = 0; while(list.size()>0) { int y = list.get(0); int z = 0; if(count.containsKey(y+1)) { z = count.get(y) + count.get(y+1); } else { z = count.get(y); } if(z>ans) { ans = z; } while(list.size()>0 && list.get(0)==y) { list.remove(0); } } System.out.println(ans); } }