#include <bits/stdc++.h>
using namespace std;
long long sumarraybegin(vector<long long> &w, int j, int n) {
  int sum = 0;
  for (int i = j; i < n; i++) {
    sum++;
  }
  return sum - 1;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i);
  }
  vector<long long> k(m + 1);
  long long ans = 1;
  long long j = 0;
  for (int i = 0; i < m; i++) {
    k.at(i) = sumarraybegin(a, j, a.at(i));
    j = a.at(i);
    if (i == (m - 1)) {
      k.at(i + 1) = sumarraybegin(a, a.at(i), n);
    }
  }
  for (int i = 0; i < m + 1; i++) {
    ans *= k.at(i);
  }
  cout << ans % 1000000007 << endl;
}
