#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M, sum = 0;
  cin >> N >> M;
  vector<int> a, renzoku, wa;
  a.resize(M);
  renzoku.resize(N);
  wa.resize(N);
  for (int i = 0; i < M; i++) cin >> a[i];
  renzoku[0] = a[0] - 1;
  for (int t = 1; t < M; t++) {
    renzoku[t] = a[t + 2] - a[t + 1] - 1;
  }
  wa[0] = 0;
  for (int j = 0; j < M; j++) {
    wa[j + 1] += wa[j] + a[j];
  }
  for (int k = 2; k < M; k++) {
    sum += wa[k - 2] * 2 + 1;
  }
  cout << 1000000007 % sum;
}
