#include <bits/stdc++.h>
using namespace std;
long long mod = 1E9 + 7;
int main() {
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < (int)(N); i++) cin >> a[i];
  long long dp[N + 1][K + 1];
  for (int i = 0; i < (int)(K + 1); i++)
    for (int j = 0; j < (int)(N + 1); j++) dp[j][i] = 0;
  dp[0][0] = 1;
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(K + 1); j++) {
      dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
      if (j + a[i] + 1 <= K) {
        dp[i + 1][j + a[i] + 1] = (dp[i + 1][j + a[i] + 1] - dp[i][j]) % mod;
      }
    }
    for (int j = 0; j < (int)(K); j++) {
      dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i + 1][j]) % mod;
    }
  }
  cout << dp[N][K] << endl;
}
