#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j, n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  for (i = 0; i < n; i++) cin >> a[i];
  int mod = 1000000007;
  vector<vector<long long int>> poss(n + 1);
  poss[1] = vector<long long int>(k + 1, 0);
  for (i = 0; i <= k; i++) {
    if (i <= a[0]) poss[1][i] = 1;
  }
  for (i = 2; i <= n; i++) {
    poss[i] = vector<long long int>(k + 1, 0);
    long long int sum = 0;
    for (j = 0; j <= k; j++) {
      if (j <= a[i - 1])
        sum = (sum + poss[i - 1][j]) % mod;
      else {
        sum = (sum + poss[i - 1][j] - poss[i - 1][j - a[i - 1] - 1]) % mod;
      }
      poss[i][j] = sum;
    }
  }
  cout << poss[n][k] << endl;
}
