#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a, b, c;
  cin >> a >> b;
  int chart[a + 1][b + 1];
  int candy[b];
  for (int i = 0; i < b; i++) cin >> candy[i];
  for (int i = 0; i < a + 1; i++) {
    for (int j = 0; j < b + 1; j++) {
      if (j == 0) {
        chart[i][j] = 1;
        continue;
      } else if (i == 0) {
        chart[i][j] = 0;
        continue;
      }
      if (j <= candy[i - 1]) {
        chart[i][j] = (chart[i - 1][j] + chart[i][j - 1]) % 1000000007;
      } else {
        chart[i][j] = (chart[i][j - 1] - chart[i - 1][j - candy[i - 1] - 1] +
                       1000000009) %
                      1000000007;
      }
    }
  }
  cout << chart[a][b] << endl;
}
