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