#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, mod = 1000000007;
  cin >> n >> k;
  vector<int> A(n, 0);
  for (int i = 0; i < n; i++) cin >> A[i];
  vector<vector<long long int>> dp(n, vector<long long int>(k + 1, 0));
  vector<vector<long long int>> prefix(n, vector<long long int>(k + 1, 0));
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
    prefix[i][0] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i == 0) {
        if (j <= A[i]) dp[i][j] = 1;
      } else {
        int index = max(0, j - A[i]);
        if (index == 0)
          dp[i][j] = prefix[i - 1][j];
        else
          dp[i][j] = (prefix[i - 1][j] - prefix[i - 1][index - 1]) % mod;
      }
      prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % mod;
    }
  }
  cout << dp[n - 1][k];
}
