import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : m : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- sequence . replicate m $ unsafeSignedDecimal <$> T.getLine :: IO [Int]
  let
    bs = unfoldr next (0, as)
      where
        next (i, as@(a : as')) | i < a = Just (True, (succ i, as))
                               | otherwise = Just (False, (succ i, as'))
        next (i, _) | i < n = Just (True, (succ i, []))
                    | otherwise = Nothing
    k = fst . foldr step (1, 0) $ bs
      where
        step True (k, l) = ((k + l) `mod` modulus, k)
        step False (k, _) = (0, k)
  print k

modulus = 10 ^ 9 + 7

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
