#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int> > dp(n, vector<int>(k + 1));
  vector<vector<long long int> > prefix(n, vector<long long int>(k + 1, 0));
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
    prefix[i][0] = 1;
  }
  for (int j = 1; j <= a[0]; j++) {
    dp[0][j] = 1;
    prefix[0][j] = prefix[0][j - 1] + 1;
  }
  for (int j = a[0] + 1; j <= k; j++) {
    prefix[0][j] = prefix[0][j - 1];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = (prefix[i - 1][j] -
                  (j - a[i] - 1 >= 0 ? prefix[i - 1][j - a[i] - 1] : 0)) %
                 1000000007;
      prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % 1000000007;
    }
  }
  cout << dp[n - 1][k] << endl;
}
