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(); int[] a = new int[n]; Map map = new HashMap(); for(int a_i=0; a_i < n; a_i++){ a[a_i] = in.nextInt(); if(map.get(a[a_i])==null){ map.put(a[a_i],1); } else { map.put(a[a_i], map.get(a[a_i]) + 1); } } int max=0; for(Map.Entry entry : map.entrySet()) { int key = entry.getKey(); int value = entry.getValue(); if(map.get(key-1)!=null){ int combDown = value + map.get(key-1); if(combDown>max){ max = combDown; } } else { int combDown = value; if(combDown>max){ max = combDown; } } if(map.get(key+1)!=null){ int combUp = value + map.get(key+1); if(combUp>max){ max = combUp; } } else { int combUp = value; if(combUp>max){ max = combUp; } } } System.out.println(max); } }