#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  vector<vector<int> > dp(n, vector<int>(k + 1));
  for (int i = 0; i < (int)(n); ++i) {
    if (i == 0) {
      for (int j = 0; j < (int)(k + 1); ++j) {
        if (j <= a[i]) {
          dp[i][j] = 1;
        } else {
          dp[i][j] = 0;
        }
      }
      continue;
    }
    vector<int> tmp(k + 1);
    for (int j = 0; j < (int)(k + 1); ++j) {
      if (j == 0) {
        tmp[j] = (tmp[j] + dp[i - 1][j]) % MOD;
        continue;
      }
      if (j <= a[i])
        tmp[j] = (tmp[j] + tmp[j - 1] + dp[i - 1][j]) % MOD;
      else {
        tmp[j] =
            (dp[i - 1][j] + tmp[j] + tmp[j - 1] - dp[i - 1][j - a[i]]) % MOD;
      }
    }
    for (int j = 0; j < (int)(k + 1); ++j) {
      dp[i][j] = (dp[i][j] + tmp[j]) % MOD;
    }
  }
  cout << dp[n - 1][k];
}
