#include <bits/stdc++.h>
using namespace std;
const int m = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<vector<int>> dp(n + 1, vector<int>(k + 1));
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= k; i++) {
    dp[0][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    vector<int> prefix(k + 1);
    prefix[0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++) {
      prefix[j] = prefix[j - 1] + dp[i - 1][j];
      prefix[j] %= m;
    }
    for (int j = 0; j <= k; j++) {
      if (j <= a[i]) {
        dp[i][j] = prefix[j];
      } else {
        dp[i][j] = prefix[j] - prefix[j - a[i] - 1];
        dp[i][j] %= m;
      }
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
