#include <bits/stdc++.h>
using namespace std;
long long const mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
  for (int i = 0; i < n; ++i) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    vector<int> sums(k + 2, 0);
    for (int j = 0; j < k + 1; ++j) sums[j + 1] = (sums[j] + dp[i][j]) % mod;
    for (int j = 0; j < k + 1; ++j)
      dp[i + 1][j] = (sums[j + 1] - sums[max(0, j - a[i])]) % mod;
  }
  cout << dp[n][k] << endl;
  return 0;
}
