#include <bits/stdc++.h>
using namespace std;
long long int input(long long int n, vector<long long int> &ve);
long long int input(long long int n, vector<long long int> &ve) {
  long long int val;
  for (long long int i = 0; i < n; i++) {
    cin >> val;
    ve.push_back(val);
  }
  return 0;
}
long long int mod = 1e9 + 7;
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, a, k;
  vector<long long int> v;
  cin >> n >> k;
  vector<vector<long long int>> dp(n + 2, vector<long long int>(100005, 0));
  input(n, v);
  for (long long int i = 0; i < v[0] + 1; i++) {
    dp[0][i] = 1;
  }
  for (long long int i = 1; i < n; i++) {
    for (long long int j = 0; j <= k; j++) {
      dp[i][j] += dp[i - 1][j];
      dp[i][j] %= mod;
      if (j + v[i] + 1 <= k) {
        dp[i][j + v[i] + 1] -= dp[i - 1][j];
        dp[i][j + v[i] + 1] %= mod;
      }
    }
    for (long long int j = 1; j <= k; j++) {
      dp[i][j] += dp[i][j - 1];
      dp[i][j] %= mod;
    }
  }
  cout << dp[n - 1][k] << endl;
  return 0;
}
