#include <bits/stdc++.h>
using namespace std;
long long a[1000000];
int main() {
  long long n, m, x;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> x;
    a[x] = 1;
    if (a[x - 1] != 0) {
      cout << "0";
      return 0;
    }
  }
  long long s = 1, k = 0;
  for (long long i = 0; i <= n; i++) {
    if (a[i] != 0) {
      if (i != 1) s = s % 1000000007 * (i - k - 1) % 1000000007;
      k = i;
    }
  }
  s = s % 1000000007 * (n - k - 1) % 1000000007;
  cout << s;
}
