#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1LL << 61;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 10));
  dp[0][0] = 1;
  for (long long i = 0; i < n; i++) {
    vector<long long> sum(k + 1);
    for (long long j = 0; j <= k; j++) {
      (sum[j + 1] = sum[j] + dp[i][j]) %= mod;
    }
    for (long long j = 0; j <= k; j++) {
      dp[i + 1][j] = (sum[j + 1] - sum[max(0LL, j - a[i])] + mod) % mod;
    }
  }
  cout << dp[n][k] << endl;
}
