#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> v(n);
  for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
  const int M = 1000000007;
  vector<vector<int> > dp(n + 1, vector<int>(k + 1));
  fill(dp[n].begin(), dp[n].end(), 1);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= k; ++j) {
      int l = max(0, j - v[i]);
      int r = j;
      dp[i][j] = dp[i + 1][r];
      if (l) {
        dp[i][j] += M - dp[i + 1][l - 1];
        if (dp[i][j] >= M) dp[i][j] -= M;
      }
      if (j) {
        dp[i][j] += dp[i][j - 1];
        if (dp[i][j] >= M) dp[i][j] -= M;
      }
    }
  }
  printf("%d\n", dp[0][k] - (k ? dp[0][k - 1] : 0));
  return 0;
}
