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