#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n + 1, vector<int>(k + 1, 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      int jtemp = j - a[i - 1] - 1;
      dp[i][j] = (dp[i][j - 1] +
                  (dp[i - 1][j] - (jtemp >= 0 ? dp[i - 1][jtemp] : 0))) %
                 MOD;
    }
  }
  cout << (dp[n][k] - dp[n][k - 1]);
  return 0;
}
