#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
int main() {
  ;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, k;
  cin >> n >> k;
  vector<long long int> candies(n);
  for (auto &x : candies) {
    cin >> x;
  }
  vector<vector<long long int>> dp(n, vector<long long int>(k + 1, 0));
  if (k == 0) {
    cout << 1 << "\n";
    return 0;
  }
  for (int i = 0; i <= min(k, candies[0]); i++) {
    dp[0][i] = 1;
  }
  for (int i = 1; i < n; i++) {
    vector<long long int> prefix(k);
    prefix[0] = dp[i - 1][0];
    for (int l = 1; l <= k; l++) {
      prefix[l] = prefix[l - 1] + dp[i - 1][l];
    }
    for (long long int j = k; j >= 0; j--) {
      long long int minimo = min(j, candies[i]);
      dp[i][j] =
          (prefix[j] - (j - minimo - 1 >= 0 ? prefix[j - minimo - 1] : 0)) %
          MOD;
    }
  }
  cout << dp[n - 1][k] << "\n";
  return 0;
}
