#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a;
  a.push_back(0);
  for (int i = 0; i < m; i++) {
    int A;
    cin >> A;
    a.push_back(A);
  }
  a.push_back(n);
  for (int i = 0; i < a.size() - 1; i++) {
    if (a[i] != 0 && a[i + 1] == a[i] + 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<int> sum;
  for (int i = 0; i < a.size() - 1; i++) {
    int length = a[i + 1] - a[i] - 1;
    if (length % 2 == 2) {
      int sum_E = 2;
      int b = length / 2 - 1;
      for (int i = b; i > 0; i--) {
        sum_E += length - i * 2 + 1;
      }
      sum.push_back(sum_E);
    } else {
      int sum_O = 1;
      int b = length / 2;
      for (int i = b; i > 0; i--) {
        sum_O += length - i * 2 + 1;
      }
      sum.push_back(sum_O);
    }
  }
  long long ans = 1;
  for (int i = 0; i < sum.size(); i++) {
    ans *= sum[i];
    ans %= ((long long)(1e9) + 7);
  }
  cout << ans << endl;
}
