#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  bool a[n];
  bool a_tmp;
  for (int i = 0; i < m; i++) {
    std::cin >> a_tmp;
    a[a_tmp] = true;
  }
  int safe_count = 0;
  int broken_count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      if (i < n - 1 && !a[i + 1]) {
        std::cout << "0";
        return 0;
      } else {
        broken_count++;
      }
    }
    if (a[i]) {
      safe_count++;
    }
  }
  std::cout << ((safe_count ^ 2) + broken_count % 1000000007) << std::endl;
  return 0;
}
