#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <class T, class C>
void chmax(T& a, C b) {
  a > b ?: a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  a < b ?: a = b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m, ans = 1;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int x = a[0] - 1;
  if (x % 2 == 0) {
    ans *= (pow(2, x / 2) + pow(2, (x - 1) / 2) - 1);
  } else {
    ans *= pow(2, (x + 1) / 2) - 1;
  }
  for (int i = 1; i < m; i++) {
    x = a[i] - a[i - 1] - 2;
    if (x == -1) {
      cout << "0" << endl;
      return 0;
    }
    if (x % 2 == 0) {
      ans *= (pow(2, x / 2) + pow(2, (x - 1) / 2) - 1);
    } else {
      ans *= pow(2, (x + 1) / 2) - 1;
    }
  }
  x = n - a[m - 1] - 1;
  if (x % 2 == 0) {
    ans *= (pow(2, x / 2) + pow(2, (x - 1) / 2) - 1);
  } else {
    ans *= pow(2, (x + 1) / 2) - 1;
  }
  cout << ans % 1000000007 << endl;
}
