#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> max_candies(n);
  for (int i = 0; i < n; i++) {
    cin >> max_candies[i];
  }
  vector<vector<long long>> dp(n, vector<long long>(k + 1));
  for (int i = 0; i <= min(k, max_candies[0]); i++) {
    dp[0][i] = 1;
  }
  for (int i = 1; i < n; i++) {
    long long patterns = 0;
    int window_size = min(max_candies[i], k) + 1;
    for (int total_c = 0; total_c <= k; total_c++) {
      if (total_c - window_size >= 0) {
        patterns = (patterns - dp[i - 1][total_c - window_size]) % 1000000007;
      }
      patterns = (patterns + dp[i - 1][total_c]) % 1000000007;
      dp[i][total_c] = patterns;
    }
  }
  cout << dp.back().back() << endl;
}
