#include <bits/stdc++.h>
#include <dbg.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];
  }

  // dp[i][j] - No. of ways to distribute j chocolates to the first i people
  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;
    }
  }

  // dbg(dp[2][0]);
  cout << dp[n][k] << "\n";
}
