#include <bits/stdc++.h>
const long long INF = (long long)1e9;
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  x = x % 1000000007;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = ((res % 1000000007) * (x % 1000000007)) % 1000000007;
    y = y >> 1;
    x = ((x % 1000000007) * (x % 1000000007)) % 1000000007;
  }
  return res;
}
vector<long long> pr;
void sieve(long long n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long i = 2; i <= n; i++)
    if (prime[i]) pr.push_back(i);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void we_have_choices() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long dp[k + 8][n + 8];
  for (long long i = 0; i < k + 1; i++)
    for (long long j = 0; j < n + 1; j++) dp[i][j] = 0;
  for (long long i = 0; i < n + 1; i++) dp[0][i] = 1;
  for (long long i = 0, item = 1; i < n; i++, item++) {
    long long prefix[k + 1];
    prefix[0] = dp[0][item - 1];
    for (long long j = 1; j <= k; j++)
      prefix[j] = (prefix[j - 1] + dp[j][item - 1]) % 1000000007;
    for (long long candies = 0; candies <= k; candies++) {
      long long L = candies - a[i];
      if (L <= 0)
        dp[candies][item] = (prefix[candies] % 1000000007);
      else
        dp[candies][item] =
            ((prefix[candies] % 1000000007) - (prefix[L - 1] % 1000000007)) %
            1000000007;
    }
  }
  cout << dp[k][n];
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  ;
  long long t = 1;
  while (t--) we_have_choices();
  return 0;
}
