#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, 0);
  vector<int> br(m + 2, 0);
  int tmp;
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    a.at(tmp) = 1;
    br.at(i + 1) = tmp;
    if (a.at(tmp - 1) == 1) {
      cout << "0" << endl;
      return 0;
    }
  }
  br.at(0) = -1;
  br.at(m + 1) = n + 1;
  long ans = 1;
  for (int i = 1; i < m + 2; i++) {
    tmp = br.at(i) - br.at(i - 1);
    if (tmp > 3) {
      for (int j = 0; j < tmp - 3; j++) {
        ans = ans * 2 % 1000000007;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
