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: def main():
      N = int(input())
      a = list(map(int, input().split()))
      num_dict = {}
      a.sort()
      a_max = a[N - 1]
      temp = a[0]
      sum = 1
  
      for i in range(1, N):
          if temp == a[i]:
              sum += 1
          else:
              num_dict[temp] = sum
              sum = 1
              temp = a[i]
      num_dict[a[N - 1]] = sum
  
      ans = 0
      judge = 0
      for j in range(1, a_max):
          # j=1のときは特別
          if j == 1 and j in num_dict:
              if j + 1 in num_dict:
                  judge = num_dict[j] + num_dict[j + 1]
                  ans = judge
                  continue
              else:
                  judge = num_dict[j]
                  ans = judge
                  continue
  
          if (j in num_dict) and (j - 1 in num_dict) and (j + 1 in num_dict):
              if judge <= (num_dict[j - 1] + num_dict[j] + num_dict[j + 1]):
                  judge = num_dict[j - 1] + num_dict[j] + num_dict[j + 1]
                  ans = judge
                  continue
              else:
                  continue
  
          elif (j in num_dict) and (j - 1 in num_dict):
              if judge <= (num_dict[j - 1] + num_dict[j]):
                  judge = num_dict[j - 1] + num_dict[j]
                  ans = judge
                  continue
              else:
                  continue
  
          elif (j in num_dict) and (j + 1 in num_dict):
              if judge <= (num_dict[j + 1] + num_dict[j]):
                  judge = num_dict[j + 1] + num_dict[j]
                  ans = judge
                  continue
              else:
                  continue
  
          elif (j - 1 in num_dict) and (j + 1 in num_dict):
              if judge <= (num_dict[j + 1] + num_dict[j - 1]):
                  judge = num_dict[j + 1] + num_dict[j - 1]
                  ans = judge
                  continue
              else:
                  continue
  
          elif j in num_dict:
              if judge <= (num_dict[j]):
                  judge = num_dict[j]
                  ans = judge
                  continue
              else:
                  continue
  
          else:
              continue
  
      if a_max - 1 in num_dict:
          if judge <= num_dict[a_max - 1] + num_dict[a_max]:
              ans = num_dict[a_max - 1] + num_dict[a_max]
      else:
          if judge <= num_dict[a_max]:
              ans = num_dict[a_max]
      return ans
  
  
  print(main())
  
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"}]