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