#include <bits/stdc++.h>
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main(void) {
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  int i = 0;
  int a[N];
  for (i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  int diff = 0;
  for (i = 0; i < M - 1; i++) {
    diff = a[i + 1] - a[i];
    if (diff == 1) {
      printf("0");
      return 0;
    }
  }
  int j = 0;
  int check = 0;
  long long count = 0;
  for (i = 0; i < N - 1; i++) {
    check = 0;
    for (j = 0; j < M; j++) {
      if (i + 1 == a[j]) {
        check = 1;
      } else if (i + 2 == a[j]) {
        check = 1;
      } else if (i == a[j]) {
        check = 1;
      }
    }
    if (check == 0) {
      count++;
    }
  }
  printf("%ll", modpow(2, count, 1000000007));
  return 0;
}
