#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int* a = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long** dp = new long*[n + 1];
  for (int i = 0; i <= n; i++) {
    dp[i] = new long[k + 2];
    for (int j = 0; j < k + 2; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = 0; i <= a[0]; i++) {
    dp[1][i] = 1;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = (dp[i - 1][j] % 1000000007 + dp[i][j - 1] % 1000000007) %
                   1000000007;
        if (j - a[i - 1] - 1 >= 0) {
          dp[i][j] = (dp[i][j] % 1000000007 -
                      dp[i - 1][j - 1 - a[i - 1]] % 1000000007) %
                     1000000007;
        }
      }
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
