#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long *a = new long long[m];
  for (long long i = 0; i < m; ++i) cin >> a[i];
  for (long long i = 0; i < m - 1; ++i) {
    if (a[i] + 1 == a[i + 1]) {
      cout << 0;
      return 0;
    }
  }
  long long cnt = 0, ans = 1;
  while (cnt < n) {
    bool s = 0;
    for (int i = 0; i < m; ++i) {
      if (a[i] == cnt + 1) {
        s = 1;
        break;
      }
    }
    if (s == 1)
      cnt += 2;
    else {
      cnt += 2;
      ans *= 2;
    }
    if (cnt == n - 1) {
      ans++;
      break;
    }
  }
  cout << ans % 1000000007;
  return 0;
}
