#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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 + 1, 0));
  dp[0][0] = 1;
  for (long long i = 0; i < n; i++) {
    vector<long long> b(k + 2, 0);
    for (long long j = 0; j <= k; j++) {
      b[j + 1] += b[j] + dp[i][j];
      b[j + 1] %= MOD;
    }
    for (long long j = 0; j <= k; j++) {
      dp[i + 1][j] += b[j + 1] - b[max(0LL, j - a[i])];
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
