import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (sort, groupBy)

main :: IO ()
main = do
  [n, k] <- map read <$> words <$> getLine
  unless (n == 0 && k == 0) $ do
    solve <$> replicateM k (readi B.readInt <$> B.getLine) >>= print
    main

solve :: [Int] -> Int
solve xs | y == 0 = f (length (head gys) + 1) gys
         | otherwise = maximum $ map length $ groupBy (\a b -> a + 1 == b) sxs
  where sxs@(y:ys) = sort xs
        gys = groupBy (\a b -> a + 1 == b) ys
        f ln (as:bs:css) | (last as) + 2 == (head bs) = f (max ln (length as + length bs + 1)) (bs:css)
                         | otherwise = f (max ln (length bs + 1)) (bs:css)
        f ln _ = ln

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n

