#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int n, k;
vector<int> arr;
void solve() {
  vector<int> dp1(k + 1), dp2(k + 1);
  dp1[0] = 1;
  for (int i = 0; i < n; ++i) {
    vector<int> pre(k + 2);
    for (int j = 0; j <= k; ++j) {
      pre[j + 1] = (pre[j] + dp1[j]) % MOD;
    }
    for (int j = k; ~j; --j) {
      dp2[j] = (pre[j + 1] - pre[max(0, j - arr[i])]) % MOD;
    }
    swap(dp1, dp2);
  }
  cout << dp1[k];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  arr = vector<int>(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  solve();
  return 0;
}
