#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int dp[n][k + 1];
  long long int cum[n][k + 1];
  memset(dp, 0, sizeof dp);
  memset(cum, 0, sizeof cum);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k + 1; j++) {
      if (i == 0) {
        dp[i][j] = (a[i] >= j) ? 1 : 0;
      } else {
        if (j - (a[i] + 1) < 0)
          dp[i][j] = (cum[i - 1][j]) % 1000000007;
        else
          dp[i][j] = ((cum[i - 1][j]) % 1000000007 -
                      (cum[i - 1][j - (a[i] + 1)]) % 1000000007) %
                     1000000007;
      }
      if (j > 0)
        cum[i][j] = ((dp[i][j]) % 1000000007 + (cum[i][j - 1]) % 1000000007) %
                    1000000007;
      else
        cum[i][j] = (dp[i][j]) % 1000000007;
    }
  }
  cout << dp[n - 1][k] << endl;
}
