#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 29;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
template <class T>
void chmax(T &a, const T &b) {
  a = max(a, b);
}
template <class T>
void chmin(T &a, const T &b) {
  a = min(a, b);
}
const int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(n), dp(k + 1), sum(k + 1, 0);
  for (auto &i : a) cin >> i;
  dp[0] = 1;
  for (int i = (1); i <= (k); i++) {
    dp[i] = 0;
  }
  for (int i = (0); i <= (n - 1); i++) {
    sum[0] = dp[0];
    for (int j = (1); j <= (k); j++) sum[j] = (sum[j - 1] + dp[j]) % MOD;
    for (int j = (0); j <= (k); j++)
      if (j <= a[i])
        dp[j] = sum[j];
      else {
        int s = j - a[i] - 1;
        dp[j] = (sum[j] - sum[s]) % MOD;
      }
  }
  cout << dp[k];
  return 0;
}
