import Data.Int
import Data.Ratio

main = do
  [n,m] <- map read.words<$>getLine
  as <- map read.lines<$>getContents
  print $ solve (Mod n) (map Mod as)

solve :: ModInt -> [ModInt] -> ModInt
solve n as = ans where
  (_,ans) = foldl f (0,1) stair
  f (pp, p) s = (p, s*(pp+p))
  stair = go 1 as where
    go s [] = replicate (fromEnum$n-s+1) 1
    go s (a:as)
      | s == a = 0 : go (s+1) as
      | otherwise = 1 : go (s+1) (a:as)
      
modulo = 10^9+7

newtype ModInt = Mod Int deriving (Eq)

instance Show ModInt where
  show (Mod a) = show a
instance Bounded ModInt where
  maxBound = Mod $ modulo - 1
  minBound = 0
-- Caution! If (value>=modulo), this does not work.
instance Enum ModInt where
  toEnum a = Mod $ mod a modulo
  fromEnum (Mod a) = a
instance Num ModInt where
  (Mod a) + (Mod b) = Mod $ mod (a+b) modulo
  (Mod a) * (Mod b) = Mod $ mod (a*b) modulo
  abs = id
  signum = const 1
  fromInteger a = Mod $ fromIntegral $ mod a $ fromIntegral modulo
  negate 0 = 0
  negate (Mod a) = Mod $ modulo - a
instance Fractional ModInt where
  recip a = a ^ (modulo-2)
  fromRational r = Mod (n * signum d) / Mod (abs d) where
    [n,d] = [fromIntegral] <*> ( [numerator,denominator] <*> [r] )
