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