#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> b(m);
  for (auto idx(0); idx < m; ++idx) {
    cin >> b[idx];
  }
  int ppp(1);
  int p = 0;
  for (auto idx(0); idx < m; ++idx) {
    if (idx < m - 1) {
      ppp *= (b[idx + 1] - b[idx] == 1) ? 0 : 1;
      cout << b[idx + 1] << " " << b[idx] << endl;
    }
    if (b[idx] < 3) {
      ppp *= 1;
    } else if (b[idx] >= n - 2) {
      ppp *= 1;
    } else {
      ppp *= static_cast<long long int>(round(pow(2, b[idx] - 2 - p))) %
             1000000007;
    }
    p = b[idx] + 2;
  }
  ppp *= static_cast<long long int>(round(pow(2, n - p))) % 1000000007;
  cout << ppp % 1000000007 << endl;
  return 0;
}
