#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  long long int arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long int dp[n][k + 1];
  dp[0][0] = 1;
  for (int i = 1; i <= k; ++i) {
    dp[0][i] = dp[0][i - 1];
    if (i <= arr[0]) dp[0][i]++;
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      long long int temp = max(j - arr[i], 0LL);
      if (temp < 1)
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = dp[i - 1][j] - dp[i - 1][temp - 1];
    }
    for (int j = 1; j <= k; ++j) {
      dp[i][j] = (dp[i][j] + dp[i][j - 1]) % 1000000007;
    }
  }
  if (k)
    cout << dp[n - 1][k] - dp[n - 1][k - 1];
  else
    cout << dp[n - 1][k];
  return 0;
}
