#include <bits/stdc++.h>
using namespace std;
vector<unsigned long long> numbers;
vector<unsigned long long> accumsum;
unsigned long long dp[105][100005];
unsigned long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  unsigned long long n, k;
  cin >> n >> k;
  accumsum.push_back(0);
  for (int i = 0; i < n; ++i) {
    long long e;
    cin >> e;
    numbers.push_back(e);
    if (i == 0)
      accumsum.push_back(e);
    else
      accumsum.push_back(e + accumsum.back());
  }
  for (int i = 0; i <= k; ++i) {
    if (i == 0)
      dp[n][0] = 1;
    else
      dp[n][i] = 0;
  }
  for (int i = numbers.size() - 1; i >= 0; --i) {
    long long right = k, left = k, m = 0;
    for (int j = k; j >= 0; --j) {
      long long taken = k - j;
      if (taken > accumsum[i]) break;
      if (left == right) {
        for (int h = 0; h <= min((unsigned long long)j, numbers[i]); ++h) {
          m = (m + dp[i + 1][j - h]);
          left = j - h;
        }
      } else {
        m -= dp[i + 1][j + 1];
        if (left > 0) --left, m += dp[i + 1][left];
      }
      dp[i][j] = m;
    }
  }
  cout << dp[0][k] % mod << "\n";
  return 0;
}
