#include <bits/stdc++.h>
using namespace std;
long long MAX = 1e9 + 1;
const int MOD = 1e9 + 7;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  vector<vector<int> > dp(n + 1, vector<int>(k + 1, 0));
  for (int j = 0; j <= n; j++) {
    dp[j][0] = 1;
  }
  int presum = 0;
  for (int i = 1; i <= n; i++) {
    presum += a[i];
    for (int j = 1; j <= min(presum, k); j++) {
      int l = j - a[i] - 1;
      dp[i][j] =
          (dp[i][j - 1] + dp[i - 1][j] - (l < 0 ? 0 : dp[i - 1][l])) % MOD;
    }
  }
  cout.precision(20);
  cout << dp[n][k] % MOD << endl;
}
int main() {
  solve();
  return 0;
}
