#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<long long> dp(k + 1);
  vector<long long> prefix(k + 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j == 0)
        prefix[j] = dp[j];
      else
        prefix[j] = prefix[j - 1] + dp[j];
    }
    for (int j = k; j >= 1; j--) {
      int r = j - 1;
      int l = max(0LL, j - a[i]);
      long long sum = 0;
      if (l == 0)
        sum = prefix[r];
      else
        sum = prefix[r] - prefix[l - 1];
      dp[j] += sum;
    }
  }
  cout << dp[k] % mod << endl;
  return 0;
}
