import Data.List (elemIndex)

main = do
  n <- getLine
  ln <- getLine
  let as = map (\i -> read i :: Int) $ words ln
  let xs = [(minimum as) - 1 .. (maximum as) + 1]
  let bss = map (\x -> convert x as) xs
  let ms = zipWith (\x -> \bs -> length $ filter (\b -> b == x) bs) xs bss
  let (Just i) = elemIndex (maximum ms) ms
  
  print $ ms !! i

  where
    convert :: Int -> [Int] -> [Int]
    convert _ [] = []
    convert x (a:as)
      | a - 1 == x = (a - 1):(convert x as)
      | a + 1 == x = (a + 1):(convert x as)
      | otherwise = a:(convert x as)