<?php
fscanf(STDIN, "%d %d", $N, $M);
$a =array();

$kumi = 1;
$be = 1;
for($i=0;$i<$M&&$kumi!=0;$i++){
  fscanf(STDIN, "%d", $a[]);
  $nn = $a[$i]-$be;
  if($a[$i]==$be&&$a[$i]!=1){
   $kumi = 0; 
  }
  $be = $a[$i]+1;

  if($nn>3){
      $kumi = ($kumi%1000000007 * ($nn + pow(2,$nn-3)-1)%1000000007)%1000000007;
  }elseif($nn>0){
    $kumi = ($kumi%1000000007 * $nn%1000000007)%1000000007;
  }
}

$nn = $N-$be;
if($nn>3){
$kumi = ($kumi%1000000007 * ($nn + pow(2,$nn-3)-1)%1000000007)%1000000007;
}elseif($nn>0){
$kumi = ($kumi%1000000007 * $nn%1000000007)%1000000007;
}

  echo  ($kumi%1000000007)."\n";

?>
