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