import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

solve :: Int -> Int -> [Int] -> Int
solve n m as =
  (\(x, _, _) -> x) $
    foldl
      ( \(p, pp, a) i ->
          if not (null a) && head a == i
            then (0, p, tail a)
            else ((p + pp) `mod` 1000000007, p, a)
      )
      (1, 0, as)
      [1 .. n]

main = do
  [n, m] <- getIntList
  as <- replicateM m getInt

  print $ solve n m as