#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, K;
  cin >> n >> K;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long dp[n][K + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < K + 1 and a[0] >= i; ++i) {
    dp[0][i] = 1;
  }
  for (int i = 1; i < n; ++i) {
    long long sum = 0;
    for (int j = 0; j <= K; ++j) {
      if (j - a[i] - 1 >= 0) sum = sum - dp[i - 1][j - a[i] - 1];
      sum = (sum + dp[i - 1][j]) % 1000000007;
      dp[i][j] = (dp[i][j] + sum) % 1000000007;
    }
  }
  cout << dp[n - 1][K];
  return 0;
}
