#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  ll m = 1000000007;
  int a[M + 1];
  int dif;
  bool flag = true;
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    if (i != 0) {
      dif = a[i] - a[i - 1];
      if (dif == 1) flag = false;
    }
  }
  a[M + 1] = 0;
  if (flag == false) {
    cout << 0;
    return 0;
  }
  ll ans = 1;
  int j = 0;
  int i = 0;
  while (i < N - 1) {
    if (a[j] - i > 2) {
      ans *= 2;
    } else if (a[j] - i > 1) {
      ans *= 1;
    } else if (a[j] - i == 0) {
      j++;
    } else if (a[j] - i < 0) {
      ans *= 2;
    }
    ans %= m;
    i++;
  }
  cout << ans;
  return 0;
}
