#include <bits/stdc++.h>
template <typename T>
void vc(T t) {
  std::cout << t << " ";
}
template <typename T, typename... Args>
void vc(T t, Args... args) {
  std::cout << t << " ";
  vc(args...);
}
long long dp[102][100008];
void once() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> vi(n + 1);
  std::vector<int> si(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vi[i];
    si[i] += vi[i] + si[i - 1];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i - 1][j] += dp[i - 1][j - 1];
      dp[i - 1][j] %= 1000000007LL;
    }
    for (int j = std::max(0, k - si[n + 1 - i]); j <= k && j <= si[i]; ++j) {
      auto x = std::min(j, vi[i]);
      if (j - x != 0) {
        dp[i][j] += dp[i - 1][j] + 1000000007LL - dp[i - 1][j - x - 1];
      } else {
        dp[i][j] += dp[i - 1][j];
      }
      dp[i][j] %= 1000000007LL;
    }
  }
  std::cout << dp[n][k] << std::endl;
}
int main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  while (n--) {
    once();
  }
}
