#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 1;
  long long flag = 0;
  long long b = 0;
  long long count = 0;
  for (long long i = 0; i < m; i++) {
    long long a;
    cin >> a;
    if (a == b) {
      flag = 1;
    }
    for (long long j = b; j < a - 2; j++) {
      ans = ans * 2;
      if (ans > 1e9 + 7) ans -= 1000000007;
      count++;
    }
    b = a + 1;
  }
  for (long long j = b; j < n - 1; j++) {
    ans = ans * 2;
    if (ans > 1e9 + 7) ans -= 1000000007;
    count++;
  }
  if (flag)
    cout << 0 << endl;
  else
    cout << ans << endl;
}
