#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <class T>
using vt = vector<T>;
template <class T>
using vvt = vector<vector<T>>;
long long gcd(long long n, long long m) { return (m == 0 ? n : gcd(m, n % m)); }
long long lcm(long long n, long long m) { return (n / gcd(n, m) * m); }
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vt<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vvt<int> dp(n + 1, vt<int>(k + 2, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < k + 1; ++j) {
      if (dp[i][j] == 0) continue;
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][min(k, j + a[i]) + 1] -= dp[i][j];
    }
    for (int j = 0; j < k; ++j) (dp[i + 1][j + 1] += dp[i + 1][j]) %= mod;
  }
  cout << dp[n][k] << endl;
}
