#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[m];
  long long b[n + 1];
  long long ans;
  long long count = 1;
  for (int i = 0; i < n + 1; i++) {
    b[i] = i;
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int flag = 0;
  for (int i = 0; i < m - 1; i++) {
    if (a[i + 1] - a[i] == 1) {
      flag = 1;
      break;
    }
  }
  if (flag == 1 || a[m - 1] == b[n]) {
    cout << "0";
  } else {
    flag = 0;
    for (int i = 0; i < m; i++) {
      b[a[i]] = -1;
    }
    for (int i = 0; i <= n - 2; i++) {
      if (b[i] != -1) {
        if (b[i + 1] != -1 && b[i + 2] != -1) {
          count = (count * 2) % 1000000007;
        } else if (b[i + 1] != -1 && b[i + 2] == -1) {
          count = (count * 1) % 1000000007;
        } else if (b[i + 1] == -1 && b[i + 2] != -1) {
          count = (count * 1) % 1000000007;
        }
      }
    }
    int i = n - 1;
    if (b[i] != -1 && b[i + 1] != -1) {
      count = (count * 1) % 1000000007;
    } else if (b[i] != -1 && b[i + 1] == -1) {
      flag = 1;
    }
    long long temp = count % 1000000007;
    if (flag == 1) {
      cout << "0";
    } else {
      cout << temp % 1000000007;
    }
  }
  return 0;
}
