#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp(101, vector<long long>(100003, 0));
long long n, k;
vector<long long> a(101);
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < a[n - 1] + 1; i++) {
    dp[n - 1][i] = 1;
  }
  vector<vector<long long>> pre(n, vector<long long>(k + 2, 0));
  pre[n - 1][0] = 0;
  for (long long i = 1; i <= k + 1; i++) {
    pre[n - 1][i] = pre[n - 1][i - 1] + dp[n - 1][i - 1];
    pre[n - 1][i] %= 1000000007;
  }
  for (long long i = n - 2; i >= 0; --i) {
    dp[i][0] = 1;
    pre[i][0] = 0;
    for (long long j = 1; j <= k; j++) {
      long long tem = j - a[i];
      if (tem < 0) tem = 0;
      dp[i][j] = pre[i + 1][j + 1] - pre[i + 1][tem];
      dp[i][j] %= 1000000007;
      pre[i][j] = pre[i][j - 1] + dp[i][j - 1];
      pre[i][j] %= 1000000007;
    }
    pre[i][k + 1] = pre[i][k] + dp[i][k];
    pre[i][k + 1] %= 1000000007;
  }
  cout << dp[0][k] << "\n";
}
