#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
static bool compare(vector<int> v1, vector<int> v2) {
  return (v1[1] < v2[1] || (v1[1] == v2[1] && v1[0] < v2[0]));
}
bool isprime(long long int x) {
  for (long long int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int numberOfSubarrays(vector<int>& nums, int k) {
  int n = nums.size();
  for (int i = 0; i < n; i++) {
    if (nums[i] % 2 == 1)
      nums[i] = 1;
    else
      nums[i] = 0;
  }
  for (int i = 0; i < n; i++) cout << nums[i] << " ";
  cout << endl;
  vector<int> prsum(n);
  prsum[0] = nums[0];
  map<int, int> mp;
  mp[prsum[0]]++;
  for (int i = 1; i < n; i++) {
    prsum[i] = prsum[i - 1] + nums[i];
    mp[prsum[i]]++;
  }
  for (int i = 0; i < n; i++) cout << prsum[i] << " ";
  cout << endl;
  int ans = 0;
  for (int i = prsum[n - 1]; i >= k; i--) {
    if (i != k) {
      ans += mp[i] * mp[i - k];
    } else {
      ans += mp[i] * (mp[0] + 1);
    }
    cout << ans << endl;
  }
  return ans;
}
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n + 1];
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  vector<vector<long long int> > dp(n + 1, vector<long long int>(k + 1, 1));
  for (int i = 1; i < k + 1; i++) {
    if (a[1] >= i)
      dp[1][i] = 1;
    else
      dp[1][i] = 0;
  }
  for (int i = 2; i < n + 1; i++) {
    long long int pre[k + 1];
    pre[0] = dp[i - 1][0];
    for (int j = 1; j < k + 1; j++) {
      pre[j] = (dp[i - 1][j] + pre[j - 1]) % inf;
    }
    for (int j = 1; j < k + 1; j++) {
      if (j <= a[i])
        dp[i][j] = pre[j];
      else
        dp[i][j] = (pre[j] - pre[j - a[i] - 1]) % inf;
    }
  }
  cout << dp[n][k] % inf;
  return 0;
}
