#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1));
  vector<vector<long long> > csum(n + 1, vector<long long>(k + 1));
  for (int i = 0; i < (n + 1); i++) {
    dp[i][0] = 1;
    csum[i][0] = 1;
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += a[i - 1];
    for (int j = 1; j <= k; j++) {
      if (j <= sum) {
        dp[i][j] += dp[i - 1][j];
        dp[i][j] %= mod;
        if (a[i - 1] > 0) {
          if (j - 1 - a[i - 1] >= 0)
            dp[i][j] += abs(csum[i - 1][j - 1 - a[i - 1]] - csum[i - 1][j - 1]);
          else
            dp[i][j] += csum[i - 1][j - 1];
        }
        dp[i][j] %= mod;
      } else {
        dp[i][j] = 0;
      }
      csum[i][j] = csum[i][j - 1] + dp[i][j];
      csum[i][j] %= mod;
    }
  }
  cout << dp[n][k] << endl;
}
