#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  const int MOD = 1000000007;
  int N, K;
  cin >> N >> K;
  const int MAX_K = K + 10;
  vector<int> A(N);
  for (int i = 0; i < (N); ++i) cin >> A[i];
  vector<vector<int>> dp(N + 1, vector<int>(MAX_K));
  for (int i = 0; i < (MAX_K); ++i) {
    dp[0][i] = 1;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= MAX_K - 5; j++) {
      if (j == 0) {
        dp[i][0] = 1;
      } else {
        dp[i][j] += dp[i][j - 1];
        dp[i][j] %= MOD;
        if (j - A[i - 1] <= 0) {
          dp[i][j] += dp[i - 1][j];
          dp[i][j] %= MOD;
        } else {
          dp[i][j] += dp[i - 1][j] - dp[i - 1][j - A[i - 1] - 1];
          dp[i][j] %= MOD;
        }
      }
    }
  }
  cout << (dp[N][K] - dp[N][K - 1] + MOD) % MOD << endl;
}
