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