#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 1;
  vector<int> a(m + 1, 0);
  for (ll i = 1; i < m + 1; i++) {
    cin >> a[i];
    if (i != 1 && a[i] - a[i - 1] == 1) {
      cout << 0 << endl;
      return 0;
    }
    for (int j = a[i - 1] + 1; j < a[i] - 1; j++) {
      ans = ans * 2 % mod;
    }
  }
  for (int i = a[m] + 1; i < n - 1; i++) {
    ans = ans * 2 % mod;
  }
  cout << ans << endl;
  return 0;
}
