#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9;
const int del = 728729;
int arr[maxn];
int ps[maxn];
long long ans = 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    arr[i] = 2;
  }
  arr[n] = 1;
  arr[n - 1] = 1;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    arr[x] = 1;
    arr[x - 1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    ans *= arr[i];
    ans = ans % mod;
  }
  cout << ans;
}
