#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int solve(vector<int> &v, int n, int k) {
  vector<vector<long long> > dp(n + 2, vector<long long>(k + 2, 0));
  for (int j = 1; j <= k; j++) dp[1][j] = (j > v[1]) ? 0 : 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = (dp[i - 1][j]) % mod;
      else
        dp[i][j] = (mod + dp[i][j - 1] + dp[i - 1][j] -
                    ((j - v[i] - 1 >= 0) ? dp[i - 1][j - v[i] - 1] : 0)) %
                   mod;
    }
  }
  return dp[n][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> v(n + 1);
  for (int i = 1; i < n + 1; i++) cin >> v[i];
  cout << solve(v, n, k);
  return 0;
}
