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