#include <bits/stdc++.h>
using namespace std;
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
}
int main() {
  init();
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long it = 0; it < n; it++) cin >> a[it];
  ;
  long long dp[n + 1][k + 1];
  dp[0][0] = 1;
  for (long long i = 1; i <= k; i++) dp[0][i] = 0;
  for (long long i = 1; i <= n; i++) {
    dp[i][0] = 1;
    for (long long j = 1; j <= k; j++) {
      dp[i][j] = (dp[i][j - 1] % 1000000007LL + dp[i - 1][j] % 1000000007LL) %
                 1000000007LL;
      dp[i][j] = (dp[i][j] % 1000000007LL -
                  ((j >= a[i - 1] + 1) ? dp[i - 1][j - a[i - 1] - 1] : 0) %
                      1000000007LL) %
                 1000000007LL;
    }
  }
  cout << dp[n][k];
}
