#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> child(n);
  vector<ll> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> child[i];
  }
  for (int i = 0; i < n; i++) {
    vector<ll> pre(k + 1);
    for (int candies = k; candies >= 0; candies--) {
      int L = 1;
      int R = min(child[i], k - candies);
      if (L <= R) {
        pre[candies + L] += dp[candies];
        pre[candies + L] %= mod;
        if (candies + R + 1 <= k) {
          pre[candies + R + 1] -= dp[candies] + mod;
          pre[candies + R + 1] %= mod;
        }
      }
    }
    for (int j = 0; j < k; j++) {
      pre[j + 1] += pre[j];
    }
    for (int candies = 0; candies <= k; candies++) {
      dp[candies] = (dp[candies] + pre[candies]) % mod;
    }
  }
  cout << dp[k];
  return 0;
}
