#include <bits/stdc++.h>
const int MX = 10010896;
const int lmt = 3164;
const int N = 10000001;
using namespace std;
long long int extgcd(long long int a, long long int b, long long int& x,
                     long long int& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long int modpow(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
inline void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n + 1);
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1, 1));
  for (long long int j = 1; j <= k; j++) {
    dp[0][j] = 0;
  }
  vector<long long int> pref(k + 1);
  for (long long int i = 1; i <= n; i++) {
    vector<long long int> pref(k + 1);
    pref[0] = dp[i - 1][0];
    for (long long int j = 1; j <= k; j++) {
      pref[j] = (pref[j - 1] + dp[i - 1][j]) % 1000000007;
    }
    for (long long int j = 1; j <= k; j++) {
      if (j <= a[i]) {
        dp[i][j] = pref[j];
      } else {
        long long int ignore_sm = pref[j - a[i] - 1];
        dp[i][j] = (pref[j] - ignore_sm) % 1000000007;
      }
    }
  }
  cout << dp[n][k] << "\n";
}
int main() {
  cout << fixed << setprecision(12);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1, tc = 1;
  while (t--) {
    solve();
  }
  return 0;
}
