#include <bits/stdc++.h>
using namespace std;
int main() {
  int const c = 1000000007;
  int N, K;
  cin >> N >> K;
  int a[K];
  for (int i = 0; i < K; i++) cin >> a[i];
  long long int tmp = 0;
  long long int ans = 0;
  long long int end_ans = 0;
  for (int i = 0; i < K; i++) {
    tmp = 1;
    for (int j = N, k = a[i];;) {
      if (a[i] > 0) {
        tmp *= j;
        j--;
        a[i]--;
        continue;
      } else
        break;
    }
    ans = tmp;
    end_ans += ans;
  }
  cout << end_ans % c << endl;
}
