#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<vector<int>> dp(N + 1, vector<int>(K + 1, -1));
  vector<int> a(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> a[i + 1];
  }
  for (int i = 0; i < K + 1; i++) {
    if (a[1] >= i)
      dp[1][i] = i + 1;
    else
      dp[1][i] = a[1] + 1;
  }
  for (int i = 2; i < N + 1; i++) {
    dp[i][0] = 1;
    for (int j = 1; j < K + 1; j++) {
      if (j > a[i])
        dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - a[i] - 1];
      else
        dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
      dp[i][j] %= 1000000007;
    }
  }
  if (K > 0) {
    cout << dp[N][K] - dp[N][K - 1];
    return 0;
  }
  cout << dp[N][K];
}
