#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e18;
long double PI = 3.1415926;
long long int power(long long int a, long long int b) {
  if (b == 0) {
    return 1;
  }
  long long int temp = power(a, b / 2) % mod;
  if (b % 2 == 0) {
    return (temp * temp) % mod;
  } else {
    return ((a * temp) % mod * temp) % mod;
  }
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<long long int> v;
vector<long long int>::iterator it;
map<long long int, long long int> mp;
void primeFactors(long long int n) {
  while (n % 2 == 0) {
    mp[2]++;
    n = n / 2;
  }
  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }
  if (n > 2) {
    mp[n]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n];
    for (long long int x = 0; x < n; x++) {
      cin >> a[x];
    }
    long long int dp[n + 1][k + 1];
    for (long long int x = 0; x <= n; x++) {
      for (long long int y = 0; y <= k; y++) {
        if (x == 0 || y == 0) {
          dp[x][y] = 1;
        } else if (y - a[x - 1] - 1 < 0) {
          dp[x][y] = dp[x][y - 1] + dp[x - 1][y];
        } else {
          dp[x][y] = dp[x][y - 1] + dp[x - 1][y] - dp[x - 1][y - a[x - 1] - 1];
        }
        dp[x][y] %= mod;
      }
    }
    long long int ans = dp[n][k];
    if (k - 1 >= 0) {
      ans -= dp[n][k - 1];
    }
    cout << ans << "\n";
    mp.clear();
    v.clear();
  }
  return 0;
}
