#include <bits/stdc++.h>
using namespace std;
long long int p = pow(10, 9) + 7;
long long int phi(long long int n) {
  long long int result = n;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
int main() {
  long long int n, k, i, j;
  cin >> n >> k;
  long long int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  long long int dp[n][k + 1];
  dp[0][0] = 1;
  for (j = 1; j <= k; j++) {
    if (j <= arr[0])
      dp[0][j] = 1 + dp[0][j - 1];
    else
      dp[0][j] = dp[0][j - 1];
    dp[0][j] %= p;
  }
  for (i = 1; i < n; i++) {
    for (j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = 1;
      else {
        if (j <= arr[i])
          dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
        else
          dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - arr[i] - 1];
      }
      dp[i][j] %= p;
    }
  }
  if (k >= 1)
    cout << dp[n - 1][k] - dp[n - 1][k - 1];
  else
    cout << dp[n - 1][0];
  return 0;
}
