#include <bits/stdc++.h>
using namespace std;
template <class mytype>
mytype power(mytype a, mytype b, mytype m) {
  if (b == 1) return a % m;
  if (b == 0) return 1;
  mytype root = power<long long int>(a, b / 2, m);
  mytype ans = (root * root) % m;
  if (b % 2) ans = (ans * a) % m;
  return ans;
}
template <class type>
type gcd(type a, type b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
template <class type>
type mod_inv(type a, type p) {
  return power(a, p - 2, p);
}
const long long int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long int dp[k + 1];
  for (int i = 0; i <= k; i++) {
    if (i <= v[0])
      dp[i] = 1;
    else
      dp[i] = 0;
  }
  long long int sum = v[0];
  for (int i = 1; i < n; i++) {
    sum += v[i];
    int count = 0;
    for (int j = 1; j <= k && j < sum; j++) {
      if (j <= v[i])
        dp[j] = (dp[j] + dp[j - 1]) % MOD;
      else {
        dp[j] = (dp[j] + dp[j - 1] - dp[count]) % MOD;
        count++;
      }
    }
    if (sum <= k) dp[sum] = 1;
  }
  cout << dp[k] << endl;
  return 0;
}
