#include <bits/stdc++.h>
using namespace std;
vector<int> availables;
vector<int> diff;
int N;
int dfs(int node) {
  int cnt = 0;
  vector<int> buff;
  if (availables[node] == N) return 1;
  buff.push_back(node + 1);
  if (node + 2 < diff.size()) {
    if (diff[node + 2] == buff[0] && buff[0] == 1) {
      buff.push_back(node + 2);
    }
  }
  for (int i = 0; i < buff.size(); i++) {
    cnt += dfs(buff[i]);
  }
  return cnt;
}
int main() {
  int M;
  long int pattern = 1;
  int tmp;
  vector<int> a;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (i == a[cnt]) {
      cnt++;
    } else {
      availables.push_back(i);
    }
  }
  for (int i = 1; i < availables.size(); i++) {
    tmp = availables[i] - availables[i - 1];
    diff.push_back(tmp);
    if (tmp > 2) {
      cout << 0 << endl;
      ;
      return 0;
    }
  }
  pattern = dfs(0);
  cout << pattern % 1000000007 << endl;
  return 0;
}
