#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int index = 0; index < N; index++) cin >> a[index];
  vector<long long> DP(K + 1);
  DP[0] = 1;
  for (int index = 0; index < N; index++) {
    vector<long long> DP2 = DP;
    for (int num_candy = 1; num_candy <= K; num_candy++) {
      DP2[num_candy] = (DP2[num_candy] + DP2[num_candy - 1]) % 1000000007;
      if ((num_candy - a[index]) > 0)
        DP2[num_candy] =
            (DP2[num_candy] - DP[num_candy - a[index] - 1]) % 1000000007;
    }
    DP = DP2;
  }
  cout << DP[K] << endl;
}
