#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int* a;
  cin >> n >> m;
  a = new int[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count = 0;
  int r = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 == a[r]) {
      if (i + 2 == a[r + 1]) {
        cout << 0 << endl;
        return 0;
      } else {
        i++;
        r++;
      }
    } else {
      if (i + 2 == a[r]) {
        if (i + 3 == a[r + 1]) {
          cout << 0 << endl;
        } else {
          i += 2;
          r++;
        }
      } else {
        count = count << 1;
        count = count % 1000000007;
      }
    }
  }
}
