#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 0));
  for (int i = (0); i < (n + 1); ++i) dp[i][0] = 1;
  for (int i = (0); i < (n); ++i)
    for (int j = (1); j < (k + 1); ++j) {
      if (j - 1 - a[i] < 0)
        dp[i + 1][j] = (dp[i][j] + dp[i + 1][j - 1]) % MOD;
      else
        dp[i + 1][j] =
            (dp[i][j] + dp[i + 1][j - 1] - dp[i][j - 1 - a[i]]) % MOD;
    }
  cout << dp[n][k] << '\n';
  return 0;
}
