#include <bits/stdc++.h>
using namespace std;
long long int modF = 1e9 + 7;
long long int INF = 1e11;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1));
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = 1;
      } else if (i == 0) {
        dp[i][j] = dp[i][j - 1];
      } else {
        int h = j - a[i - 1];
        if (h <= 0)
          dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % modF;
        else
          dp[i][j] =
              ((dp[i - 1][j] - dp[i - 1][h - 1]) % modF + dp[i][j - 1]) % modF;
      }
    }
  }
  if (k == 0) {
    cout << 1 << "\n";
    return;
  }
  cout << dp[n][k] - dp[n][k - 1] << "\n";
}
int main() {
  solve();
  return 0;
}
