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