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