#include <bits/stdc++.h>
using namespace std;
using std::swap;
std::vector<int> a;
long long int g = 0;
void cas(int x, int y) {
  int step1, step2;
  step1 = x + 1;
  step2 = x + 2;
  if (step1 < y)
    cas(step1, y);
  else if (step1 == y)
    ++g;
  if (step2 < y)
    cas(step2, y);
  else if (step2 == y)
    ++g;
}
int main() {
  int N, M;
  long long int t = 1;
  cin >> N >> M;
  a.resize(M);
  for (int i = 0; i < M; ++i) {
    cin >> a[i];
  }
  cas(0, a[0] - 1);
  if (g == 0) ++g;
  t *= g;
  for (int i = 0; i < M - 1; ++i) {
    g = 0;
    cas(a[i] + 1, a[i + 1] - 1);
    if (g == 0) ++g;
    t *= g;
  }
  g = 0;
  cas(a[M - 1] + 1, N);
  if (g == 0) ++g;
  t *= g;
  t %= 1000000007;
  cout << t << "\n";
  return 0;
}
