import Data.List

main :: IO ()
main = do
  _ <- getLine
  ls <- fmap read . words <$> getLine :: IO [Int]
  print $ solve ls

solve :: [Int] -> Int
solve ls = maximum $ fmap (count ls') ls' where
  ls' = ls ++ fmap (+ 1) ls ++ fmap (+ (-1)) ls

count :: [Int] -> Int -> Int
count ls val = foldl' (\c v -> if v == val then c + 1 else c) 0 ls
