#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  long long ans = 0;
  cin >> N >> M;
  vector<long long> a(M), A(N + 2);
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    if (a[i] != 1) {
      A[a[i]] = 1;
      A[a[i] - 1] = 1;
      A[a[i] - 2] = 1;
    } else if (a[i] == 1) {
      A[1] = 1;
      A[0] = 1;
    }
  }
  for (int i = 0; i < M - 1; i++) {
    if (abs(a[i] - a[i + 1]) == 1) {
      cout << 0 << endl;
      return 0;
    }
    A[N + 1] = 1;
    A[N] = 1;
    A[N - 1] = 1;
  }
  for (int i = 0; i < N + 2; i++) {
    if (A[i] != 1) {
      ans += 2;
    }
  }
  cout << ans % 1000000007 << endl;
}
