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