#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
constexpr int MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < (int)(n); ++i) {
    cin >> a[i];
  }
  vector<vll> dp(n, vll(k + 1, 0));
  for (int j = 0; j < (int)(k + 1); ++j) {
    dp[0][j] = j <= a[0] ? 1 : 0;
  }
  for (int i = 1; i < (int)(n); ++i) {
    ll sum = 0;
    for (int j = 0; j < (int)(k + 1); ++j) {
      if (j <= a[i]) {
        sum = (sum + dp[i - 1][j]) % MOD;
      } else {
        sum = (sum + dp[i - 1][j] - dp[i - 1][j - a[i]] + MOD) % MOD;
      }
      dp[i][j] = sum;
    }
  }
  cout << dp[n - 1][k] << endl;
  return 0;
}
