#include <bits/stdc++.h>
using namespace std;
long long solve(long long arr[], long long n, long long k) {
  long long dp[n + 1][k + 1];
  for (long long i = 0; i <= k; i++) dp[1][i] = (i <= arr[1]) ? 1 : 0;
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = (10000000007 + dp[i][j - 1] + dp[i - 1][j] -
                    ((j - arr[i] - 1) >= 0 ? dp[i - 1][j - arr[i] - 1] : 0)) %
                   10000000007;
    }
  }
  return dp[n][k];
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  cout << solve(arr, n, k);
}
