#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dp;
vector<int> v;
int ways(int n, int candies) {
  if (dp[n][candies] != -1) {
    return dp[n][candies];
  }
  int ans = 0;
  ans = (ways(n, candies - 1) + ways(n - 1, candies)) % 1000000007;
  ;
  if (candies >= (v[n] + 1)) {
    ans -= ways(n - 1, candies - v[n] - 1);
    ans %= 1000000007;
    ;
  }
  return dp[n][candies] = ans;
}
void solve() {
  int n, k;
  cin >> n >> k;
  dp.resize(n, vector<int>(k + 1, -1));
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int x = min(v[0], k);
  for (int i = 0; i <= x; i++) {
    dp[0][i] = 1;
  }
  for (int i = x + 1; i <= k; i++) {
    dp[0][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % 1000000007;
      if (j >= (v[i] + 1)) {
        dp[i][j] -= dp[i - 1][j - v[i] - 1] % 1000000007;
        ;
      }
    }
  }
  cout << dp[n - 1][k] << "\n";
}
int main() {
  cout.precision(10);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
