#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, n, m, k, q, x, a, b, c, d, y, l, r;
  cin >> n >> k;
  vector<int> v(n + 1);
  long long dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= k; i++) {
    dp[0][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j <= v[i]) {
        dp[i][j] = dp[i - 1][j];
        dp[i][j] %= mod;
      } else {
        dp[i][j] = dp[i - 1][j] - dp[i - 1][j - v[i] - 1];
        dp[i][j] %= mod;
      }
    }
    for (int j = 1; j <= k && i != n; j++) {
      dp[i][j] += dp[i][j - 1];
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
