#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n, 0);
  vector<int> sum(k + 1, 0);
  vector<int> dp(k + 1, 0);
  long long sm = 0;
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  for (int i = 0; i <= k; i++) {
    if (i <= vec[0]) sum[i]++;
    if (i > 0) sum[i] = (sum[i] + sum[i - 1]) % 1000000007;
    ;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      int sub = ((j - vec[i] - 1) < 0) ? 0 : sum[j - vec[i] - 1];
      dp[j] = sum[j] - sub;
      if (j > 0) dp[j] = (dp[j] + dp[j - 1]) % 1000000007;
      ;
    }
    sum = dp;
  }
  int ans = sum[k] - sum[k - 1];
  cout << ans << endl;
}
