#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  long long curr = 0;
  for (long long i = 0; i <= k; i++) {
    if (i <= a[0]) curr += 1;
    dp[1][i] = curr;
  }
  for (long long i = 0; i <= n; i++) dp[i][0] = 1;
  for (long long i = 2; i <= n; i++) {
    curr = 1;
    for (long long j = 1; j <= k; j++) {
      long long sub = 0;
      if (j - a[i - 1] <= 0) {
        sub = (dp[i - 1][j]) % 1000000007;
      } else {
        sub = (dp[i - 1][j] - dp[i - 1][j - a[i - 1] - 1] + 1000000007) %
              1000000007;
      }
      curr = (curr + sub) % 1000000007;
      dp[i][j] = curr;
    }
  }
  cout << (dp[n][k] - dp[n][k - 1] + 1000000007) % 1000000007;
  return 0;
}
