#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<int> sum(k + 1, 1);
  for (int i = 0; i < n; i++) {
    vector<int> new_dp(k + 1, 0);
    for (int j = k; j >= 0; j--) {
      if (j - arr[i] > 0) new_dp[j] = (sum[j] - sum[j - arr[i] - 1]) % mod;
      if (j <= arr[i]) new_dp[j] = (sum[j]) % mod;
    }
    sum.assign(k + 1, 0);
    for (int j = 0; j < k + 1; j++) {
      if (j == 0)
        sum[j] = new_dp[j] % mod;
      else {
        sum[j] = (sum[j - 1] + new_dp[j]) % mod;
      }
    }
    dp = new_dp;
  }
  cout << dp[k] % mod << endl;
}
