#include <bits/stdc++.h>
using namespace std;
long long solve(vector<long long>& vec, long long n, long long k) {
  long long dp[n + 2][k + 2];
  for (long long j = 0; j <= k; j++) dp[1][j] = (j > vec[1]) ? 0 : 1;
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = dp[i - 1][j];
      else {
        dp[i][j] = (1000000007 + dp[i][j - 1] + dp[i - 1][j] -
                    ((j > vec[i] - 1 > 0) ? dp[i - 1][j - vec[i] - 1] : 0)) %
                   1000000007;
      }
    }
  }
  return dp[n][k];
}
signed main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> vec(n + 1);
  for (long long i = 1; i <= n; i++) cin >> vec[i];
  cout << solve(vec, n, k);
}
