#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e18 + 5;
void solve() {
  int n, k, i, j;
  cin >> n >> k;
  int ps[k + 2][n], dp[k + 1][n], A[n];
  for (i = 0; i < n; i++) cin >> A[i];
  for (j = 0; j < n; j++) ps[0][j] = 0;
  for (i = 0; i <= k; i++) {
    dp[i][n - 1] = ((i <= A[n - 1]) ? 1 : 0);
    ps[i + 1][n - 1] = ps[i][n - 1] + dp[i][n - 1];
  }
  for (j = n - 2; j >= 0; j--) {
    for (i = 0; i <= k; i++) {
      int low, high;
      low = max(0, i - A[j]);
      high = i;
      dp[i][j] = (ps[high + 1][j + 1] - ps[low][j + 1]) % 1000000007;
      ps[i + 1][j] = (ps[i][j] + dp[i][j]) % 1000000007;
    }
  }
  cout << dp[k][0] % 1000000007 << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
