#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
inline long long power(long long a, long long n, long long m) {
  if (n == 0) return 1;
  long long p = power(a, n / 2, m);
  p = (p * p) % m;
  if (n % 2)
    return (p * a) % m;
  else
    return p;
}
const long long MOD = 1e9 + 7;
const int N = int(3e5) + 999;
int n, k;
void add(int &a, int b) {
  a = a + b;
  if (a >= MOD) a -= MOD;
}
void sub(int &a, int b) {}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> k;
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int lmt;
    cin >> lmt;
    for (int used = k; used >= 0; used--) {
      int tmp = dp[used];
      vector<int> fake(k + 1, 0);
      int l = used + 1;
      int r = used + min(lmt, k - used);
      if (l <= r) {
        add(fake[l], tmp);
        if (r + 1 <= k) fake[r + 1] -= tmp;
      }
      int pp = 0;
      for (int i = 0; i <= k; i++) {
        pp = (pp + fake[i]) % MOD;
        while (pp < 0) pp += MOD;
        dp[i] = (dp[i] + pp) % MOD;
      }
    }
  }
  cout << dp[k];
  return 0;
}
