#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1000000007;
int main() {
  int n, k;
  vector<int> a;
  vector<vector<unsigned long long> > dp;
  vector<unsigned long long> pre;
  cin >> n >> k;
  a.assign(n + 1, 0);
  dp.assign(k + 1, vector<unsigned long long>(n + 1, 0));
  pre.assign(k + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= n; i++) {
    dp[0][i] = 1;
  }
  pre[0] = dp[0][n];
  for (int i = 1; i <= k; i++) {
    pre[i] = pre[i - 1] + dp[i][n];
  }
  for (int j = n - 1; j >= 0; j--) {
    for (int i = 0; i <= k; i++) {
      dp[i][j] =
          (pre[i] - pre[max(0, i - a[j])] + dp[max(0, i - a[j])][j + 1]) % mod;
    }
    pre[0] = dp[0][j];
    for (int i = 1; i <= k; i++) {
      pre[i] = (pre[i - 1] + dp[i][j]) % mod;
    }
  }
  cout << dp[k][0] << "\n";
  return 0;
}
