#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp;
vector<long long> a;
const long long mod = 1e+9 + 7;
void solve() {
  int n, K;
  cin >> n >> K;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp.assign(2, vector<long long>(K + 1, 0));
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += a[i];
    for (int k = 0; k <= min(cnt, K); k++) {
      if (i == 0) {
        dp[i & 1][k] = 1;
      } else {
        int l = max(0, (int)(k - a[i]));
        int r = k;
        dp[i & 1][k] = dp[(i + 1) & 1][r];
        if (l > 0)
          dp[i & 1][k] = (mod + dp[i & 1][k] - dp[(i + 1) & 1][l - 1]) % mod;
        dp[i & 1][k] %= mod;
      }
    }
    for (int k = 1; i < n - 1 && k <= K; k++) {
      dp[i & 1][k] += dp[i & 1][k - 1];
    }
  }
  cout << dp[(n - 1) & 1][K] % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
