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(); HashMap map = new HashMap<>(); for(int a_i=0; a_i < n; a_i++){ int next = in.nextInt(); if(!map.containsKey(next)) { map.put(next, 1); } else { map.put(next, map.get(next) + 1); } } int max = 0; for(Integer i : map.keySet()) { int thisMax = map.get(i); if(map.containsKey(i - 1)) { thisMax = Math.max(map.get(i) + map.get(i - 1), thisMax); } if(map.containsKey(i + 1)) { thisMax = Math.max(map.get(i) + map.get(i + 1), thisMax); } max = Math.max(thisMax, max); } System.out.println(max); } }