#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (auto i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (auto i = 1; i <= n; ++i) {
    vector<int> prefix(k + 1, 0);
    prefix[0] = dp[i - 1][0];
    for (auto m = 1; m <= k; ++m) {
      prefix[m] = (prefix[m - 1] + dp[i - 1][m]) % MOD;
    }
    for (auto j = 0; j <= k; ++j) {
      dp[i][j] =
          (prefix[j] - (j - a[i] - 1 >= 0 ? prefix[j - a[i] - 1] : 0)) % MOD;
    }
  }
  cout << dp[n][k] << "\n";
}
