#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long N, M, w;
  int j = 0;
  cin >> N >> M;
  vector<unsigned long long> ana(M);
  for (int i = 0; i < M; i++) {
    cin >> ana.at(i);
  }
  for (int i = 0; i < M; i++) {
    if (ana.at(i + 1) - ana.at(i) < 2) {
      j = j + 1;
    }
  }
  if (j > 0) {
    w = 2 ^ (N - M);
    w = w % 1000000007;
    cout << w << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}
