#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
void add(long long &a, long long b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> aa(n + 1);
  for (int i = 1; i < n + 1; ++i) {
    cin >> aa[i];
  }
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i < n + 1; ++i) {
    vector<long long> sum(k + 2, 0);
    for (int j = 1; j < k + 2; ++j) {
      sum[j] = (sum[j - 1] + dp[i - 1][j - 1]) % mod;
    }
    for (int j = 0; j < k + 1; ++j) {
      add(dp[i][j], sum[j + 1] - sum[max(0, j - aa[i])]);
    }
  }
  cout << (dp[n][k]) << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
