#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n + 1][k + 1];
  for (int i = 0; i < n; i++) dp[i][0] = 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 1; j <= k; j++) {
      if (i == n - 1) {
        if (j <= a[i])
          dp[i][j] = dp[i][j - 1] + 1;
        else
          dp[i][j] = dp[i][j - 1];
      } else {
        int lo = max(0, j - a[i]), hi = j;
        dp[i][j] = dp[i][j - 1] +
                   ((lo == 0) ? dp[i + 1][hi]
                              : dp[i + 1][hi] - dp[i + 1][lo - 1] + mod);
        dp[i][j] = dp[i][j] % mod;
      }
    }
  }
  cout << (dp[0][k] - dp[0][k - 1] + mod) % mod << endl;
}
