#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod = 1000000007;
const int LIM = 100005;
long long fpow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void sieve(long long n) {
  bool prime[5 * LIM];
  memset(prime, true, sizeof(prime));
  long long rootn = (long long)sqrt(n);
  for (long long p = 2; p <= rootn; p++)
    if (prime[p] == true)
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
  prime[1] = 0;
}
long long cnt, sum, mid, mx = -1e17, mn = 1e17, a[2 * LIM];
long long n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for ((i) = 1; (i) <= (n); (i)++) {
    cin >> a[i];
  }
  vector<long long> dp(k + k + 2), pre(k + k + 2);
  for (i = 0; i <= min(a[1], k); i++) {
    dp[i] = 1;
  }
  for (i = 0; i <= min(a[1], k); i++) {
    pre[i] = pre[i - 1] + dp[i];
  }
  sum = a[1];
  for (i = 2; i <= n; i++) {
    sum += a[i];
    for (j = 0; j <= min(sum, k); j++) {
      dp[j] = (pre[j] - ((j - a[i] - 1) >= 0 ? pre[j - a[i] - 1] : 0)) % mod;
    }
    pre.clear();
    for (l = 0; l <= min(sum, k); l++) {
      pre[l] = pre[l - 1] + dp[l];
    }
  }
  cout << dp[k];
}
