#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  constexpr ll MOD = 1e9 + 7;
  int n, k;
  cin >> n >> k;
  array<vector<ll>, 2> dp{vector<ll>(k + 1), vector<ll>(k + 1)};
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    ll sum = 1;
    auto& pdp = dp[(i % 2) ^ 1];
    auto& cdp = dp[i % 2];
    pdp[0] = 1;
    cdp[0] = 1;
    for (int s = 1; s <= k; s++) {
      sum += pdp[s];
      cdp[s] = sum;
      if (s - a >= 0) sum += MOD - pdp[s - a];
      sum %= MOD;
    }
  }
  cout << dp[n % 2][k] << endl;
  return 0;
}
