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 n k <$> replicateM k (readi B.readInt <$> B.getLine) >>= print
    main

solve :: Int -> Int -> [Int] -> Int
solve n k xs | k == 1 = 1
             | y == 0 = maximum $ zipWith f gys (tail 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 [] ys = length ys + (if head ys == 1 then 0 else 1)
        f xs [] = length xs + (if last xs == n then 0 else 1)
        f xs ys | last xs + 2 == head ys = length xs + length ys + 1
                | otherwise = max (length xs) (length ys) + 1

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

