#include <bits/stdc++.h>
using namespace std;
int main() {
  long long 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];
  long long int sum[n][k + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = 0;
      if (i == 0) {
        if (j <= arr[0]) {
          dp[i][j] = 1;
        } else {
          dp[i][j] = 0;
        }
        if (j == 0) {
          sum[i][j] = dp[i][j];
        } else {
          sum[i][j] = (sum[i][j - 1] + dp[i][j]) % 1000000007;
        }
      } else {
        if (arr[i] >= j) {
          dp[i][j] = sum[i - 1][j] % 1000000007;
        } else {
          dp[i][j] = (sum[i - 1][j] - sum[i - 1][j - arr[i] - 1]) % 1000000007;
        }
        if (j == 0) {
          sum[i][j] = dp[i][j] % 1000000007;
        } else {
          sum[i][j] = (sum[i][j - 1] + dp[i][j]) % 1000000007;
        }
      }
    }
  }
  cout << dp[n - 1][k] % 1000000007 << "\n";
  return 0;
}
