#include <bits/stdc++.h>
using namespace std;
long long inf = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(m + 2);
  vector<long long> b(m - 1);
  for (int i = 1; i < m + 2; ++i) {
    cin >> a[i];
  }
  a[0] = 0;
  a[m + 2] = n;
  for (int i = 1; i < m + 2; ++i) {
    b[i - 1] = a[i] - a[i - 1];
  }
  long long sum = 1;
  for (int i = 0; i < m - 1; ++i) {
    int c = b[i] / 2;
    long long z = pow(2, c);
    sum *= z;
  }
  long long res = sum % inf;
  cout << res << endl;
}
