#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << fixed << setprecision(11);
  int N, K;
  cin >> N >> K;
  vector<int> a(N + 1);
  for (int i = 1; i <= N; i++) cin >> a[i];
  vector<vector<int> > dp(N + 1, vector<int>(K + 1, 0));
  for (int i = 0; i <= N; i++) dp[i][0] = 1;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= K; j++) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % 1000000007;
      if (j > a[i])
        dp[i][j] = (dp[i][j] - dp[i - 1][j - a[i] - 1]) % 1000000007;
    }
  cout << dp[N][K] << endl;
  return 0;
}
