#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, ans = 0;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m - 1; i++) {
    a[i] = a[i] + 1;
    if (a[i] == a[i + 1]) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int j = 0; j < n - 1; j++) {
    ans = j + 1;
  }
  cout << (ans - m * 2) % 1000000007 << endl;
}
