#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T x, T y) {
  if (!y) return x;
  return gcd(y, x % y);
}
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  long long dp[n + 1][k + 1];
  int a[n + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dp[i][0] = 1;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
      if (j - a[i] >= 1) dp[i][j] = (dp[i][j] - dp[i - 1][j - a[i] - 1]) % MOD;
    }
  }
  cout << dp[n][k] % MOD;
  return 0;
}
