#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> candies(n);
  for (int i = 0; i < n; i++) cin >> candies[i];
  vector<int> sum(n, 0);
  sum[0] = candies[0];
  for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + candies[i];
  vector<vector<int> > dp(n, vector<int>(k + 1, 0));
  if (n == 1) {
    if (candies[0] <= k) {
      cout << 0 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  vector<vector<long long> > sumdp(n, vector<long long>(k + 1, 0));
  for (int i = 0; i < n; i++) dp[i][0] = 1, sumdp[i][0] = 1;
  for (int i = 1; i <= k && i <= candies[0]; i++) dp[0][i] = 1, sumdp[0][i] = 1;
  for (int i = 1; i <= k; i++) sumdp[0][i] += sumdp[0][i - 1];
  for (int i = 1; i < n; i++) {
    int x = 0;
    for (int j = 1; j <= min(sum[i], k); j++) {
      if (j <= candies[i]) {
        dp[i][j] = sumdp[i - 1][j] % 1000000007;
        sumdp[i][j] = dp[i][j];
      } else {
        dp[i][j] = (sumdp[i - 1][j] - sumdp[i - 1][x++]) % 1000000007;
        sumdp[i][j] = dp[i][j];
      }
    }
    for (int j = 1; j <= k; j++) {
      sumdp[i][j] += sumdp[i][j - 1];
    }
  }
  cout << max(0, dp[n - 1][k] % 1000000007) << endl;
  return 0;
}
