#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  const int64_t mod = 1e9 + 7;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  bool flag = true;
  for (int i = 1; i < m; i++) {
    if (a[i] == a[i - 1] + 1) {
      flag = false;
    }
  }
  int64_t ans = 0;
  if (flag) {
    int64_t tmp = 0;
    for (int i = 0; i < m + 1; i++) {
      if (i == m) {
        int64_t step = n - tmp + 1;
        while (step > 2) {
          ans += step - 2;
          ans %= mod;
          step -= 2;
        }
        ans++;
        ans %= mod;
      } else {
        int64_t step = a[i] - 1 - tmp + 1;
        while (step > 2) {
          ans += step - 2;
          ans %= mod;
          step -= 2;
        }
        ans++;
        ans %= mod;
      }
      tmp = a[i] + 1;
    }
  }
  if (flag)
    cout << ans << endl;
  else
    cout << 0 << endl;
}
