output_description: Print the maximum possible number of i such that a_i=X.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      a_1 a_2 .. a_N
attempt: import sys
  
  sys.setrecursionlimit(1 << 25)
  read = sys.stdin.readline
  ra = range
  enu = enumerate
  
  
  def read_ints():
      return list(map(int, read().split()))
  
  
  def read_a_int():
      return int(read())
  
  
  def read_tuple(H):
      """
      H is number of rows
      """
      ret = []
      for _ in range(H):
          ret.append(tuple(map(int, read().split())))
      return ret
  
  
  def read_col(H):
      """
      H is number of rows
      A列、B列が与えられるようなとき
      ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
      """
      ret = []
      for _ in range(H):
          ret.append(list(map(int, read().split())))
      return tuple(map(list, zip(*ret)))
  
  
  def read_matrix(H):
      """
      H is number of rows
      """
      ret = []
      for _ in range(H):
          ret.append(list(map(int, read().split())))
      return ret
      # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため
  
  
  MOD = 10**9 + 7
  INF = 2**31  # 2147483648 > 10**9
  # default import
  from collections import defaultdict, Counter, deque
  from operator import itemgetter
  from itertools import product, permutations, combinations
  from bisect import bisect_left, bisect_right  # , insort_left, insort_right
  
  N = read_a_int()
  A = read_ints()
  
  # どの数字を一番多くできるか
  n_X = [0] * (10**5 + 1)  # =Xにできる個数
  
  for a in A:
      for da in [-1, 0, 1]:
          n_X[a + da] += 1
  print(max(n_X))
  # https://atcoder.jp/contests/abc072/tasks/arc082_a
  
problem_description: Statement
  
  You are given an integer sequence of length N, a_1,a_2,...,a_N.
  
  For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or
  do nothing.
  
  After these operations, you select an integer X and count the number of i such
  that a_i=X.
  
  Maximize this count by making optimal choices.
samples: [{"input": "7\n    3 1 4 1 5 9 2", "output": "4\n    \n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4,\nthe maximum possible count.\n\n* * *"}, {"input": "10\n    0 1 2 3 4 5 6 7 8 9", "output": "3\n    \n\n* * *"}, {"input": "1\n    99999", "output": "1"}]