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