#include <bits/stdc++.h>
using namespace std;
void add_self(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
void sub_self(int &a, int b) {
  a -= b;
  if (a < 1000000007) a += 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int> fake(k + 2, 0);
    for (int j = k; j >= 0; j--) {
      int L = j + 1, R = min(j + vec[i], k);
      add_self(fake[L], dp[j]);
      sub_self(fake[R + 1], dp[j]);
    }
    int pre_sum = 0;
    for (int i = 0; i <= k; i++) {
      add_self(pre_sum, fake[i]);
      add_self(dp[i], pre_sum);
    }
  }
  cout << dp[k] << endl;
}
