#include <bits/stdc++.h>
using namespace std;
int candies(int arr[], int n, int k) {
  long long int **dp = new long long int *[n + 1];
  for (int i = 0; i <= n; i++) dp[i] = new long long int[k + 1];
  for (int j = 1; j <= k; j++) dp[0][j] = 0;
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      long long int cnt = 0;
      for (int z = 0; z <= arr[i - 1]; z++) {
        if (j - z >= 0) cnt = (cnt + dp[i - 1][j - z]) % 1000000007;
      }
      dp[i][j] = cnt;
    }
  }
  long long int ans = dp[n][k];
  for (int i = 0; i <= n; i++) delete[] dp[i];
  delete[] dp;
  return ans;
}
int candiesOptimized(int arr[], int n, int k) {
  long long int **dp = new long long int *[n + 1];
  for (int i = 0; i <= n; i++) dp[i] = new long long int[k + 1];
  long long int **prefix = new long long int *[n + 1];
  for (int i = 0; i <= n; i++) prefix[i] = new long long int[k + 1];
  for (int j = 0; j <= k; j++) {
    dp[0][j] = 0;
    prefix[0][j] = 1;
  }
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
    prefix[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      long long int cnt = prefix[i - 1][j];
      if (j - arr[i - 1] - 1 >= 0) cnt -= prefix[i - 1][j - arr[i - 1] - 1];
      dp[i][j] = cnt;
      prefix[i][j] = (prefix[i][j - 1] + cnt) % 1000000007;
    }
  }
  long long int ans = dp[n][k];
  for (int i = 0; i <= n; i++) delete[] dp[i];
  delete[] dp;
  return ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int ans = candiesOptimized(arr, n, k);
  cout << ans;
  return 0;
}
