#include <bits/stdc++.h>
using namespace std;
int m = 1e9 + 7;
void add_self(int& a, int b) {
  a = a + b;
  if (a >= m) a = a - m;
}
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) add_self(dp[j], dp[j - 1]);
    for (int j = k; j >= 0; j--) {
      int temp = j - arr[i] - 1;
      if (temp >= 0) dp[j] = dp[j] - dp[temp];
    }
  }
  cout << (dp[k]);
  return 0;
}
