#include <bits/stdc++.h>
using namespace std;
int fib(int x) {
  if (x == 1 || x == 2)
    return 1;
  else
    return fib(x - 1) + fib(x - 2);
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i);
  }
  bool go = true;
  for (int i = 1; i < M; i++) {
    if (a.at(i - 1) + 1 == a.at(i)) {
      go = false;
      break;
    }
  }
  int c = 1;
  int s = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j < M; j++) {
      if (a.at(j) == i) {
        c = c * fib(s);
        s = 1;
      } else
        s++;
    }
  }
  int k;
  if (go == false)
    k = 0;
  else
    k = c;
  cout << k % 1000000007 << endl;
}
