#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <class T>
void display(const vector<T> &arr) {
  for (T a : arr) {
    cout << a << " ";
  }
  cout << endl;
  return;
}
int getNumWays(const vector<int> &candies, int k) {
  int n = candies.size();
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    vector<int> prefixSum(k + 1);
    for (int used = k; used >= 0; --used) {
      int minCandies = used + 1;
      int maxCandies = used + min(candies[i], k - used);
      if (minCandies <= maxCandies) {
        prefixSum[minCandies] += dp[used];
        if (maxCandies + 1 <= k) {
          prefixSum[maxCandies + 1] -= dp[used];
        }
      }
    }
    int prefix = 0;
    for (int j = 0; j <= k; ++j) {
      prefix = (prefix + prefixSum[j]) % mod;
      dp[j] = (dp[j] + prefix) % mod;
    }
  }
  return dp[k];
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> candies(n);
  for (int &c : candies) {
    cin >> c;
  }
  int result = getNumWays(candies, k);
  cout << result << "\n";
  return 0;
}
