#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  int prev = -1;
  int selectOne = 0;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    if (prev == a - 1) {
      cout << 0 << endl;
      return 0;
    }
    if (a - 2 == prev)
      selectOne += 2;
    else
      selectOne += 3;
    prev = a;
  }
  int ans = 1;
  for (int i = 0; i < n - 1 - selectOne; ++i) {
    ans = ans * 2 % MOD;
  }
  cout << ans << endl;
  return 0;
}
