#include <bits/stdc++.h>
using namespace std;
int m = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n + 1);
  for (int i = 1; i <= n; i++) cin >> arr[i];
  long long dp[1 + n][1 + k];
  long long sum[1 + n][1 + k];
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
    sum[i][0] = 1;
  }
  for (int j = 1; j <= k; j++) {
    dp[0][j] = 0;
    sum[0][j] = 1;
  }
  for (int child = 1; child <= n; child++) {
    for (int cand = 1; cand <= k; cand++) {
      int mx = arr[child];
      dp[child][cand] = 0;
      int mini = max(0, cand - mx);
      dp[child][cand] +=
          sum[child - 1][cand] - sum[child - 1][mini] + dp[child - 1][mini];
      dp[child][cand] %= m;
      sum[child][cand] = dp[child][cand] + sum[child][cand - 1];
      sum[child][cand] %= m;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
