#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < (m); i++) cin >> a[i];
  ll ans = 1;
  vector<int> cnt(n);
  for (int i = 0; i < (n); i++) cnt[i] = 2;
  cnt[n - 1] = 1;
  for (int i = 0; i < (m); i++) {
    cnt[a[i]]--;
    cnt[a[i] - 1]--, cnt[a[i] - 2]--;
  }
  for (int i = 0; i < (n); i++) {
    ans *= cnt[i];
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
