#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int tmp = -1;
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i];
    if (a[i] - tmp == 1) {
      cout << 0 << endl;
      return 0;
    }
    tmp = a[i];
  }
  a.push_back(n + 1);
  int64_t ans = 1;
  int lwr = 0;
  for (int i = 0; i < (int)(m + 1); i++) {
    int num = a[i] - lwr - 2;
    int c1 = (1 << ((num + 1) / 2));
    int c2 = (1 << (num / 2));
    ans *= ((num > 1) ? c1 + c2 : c1);
    lwr = a[i];
  }
  cout << ans % 1000000007 << endl;
}
