#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < (N); ++i) cin >> a[i];
  long long dp[N][K + 1];
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (K + 1); ++j) dp[i][j] = 0;
  for (int i = 0; i < (N); ++i) dp[i][0] = 1;
  for (int i = 0; i < (K + 1); ++i) {
    if (i <= a[0]) dp[0][i] = 1;
  }
  long long curMax = a[0];
  for (int i = (1); i < (N); ++i) {
    curMax += a[i];
    long long s = dp[i - 1][0];
    int itr = 0;
    for (int j = (1); j < (K + 1); ++j) {
      if (j <= a[i]) {
        s = (s + dp[i - 1][j]) % 1000000007;
        dp[i][j] = s;
      }
      if (j > a[i] && j <= curMax) {
        s = (s - dp[i - 1][itr] + dp[i - 1][j]) % 1000000007;
        itr++;
        dp[i][j] = s;
      }
    }
  }
  cout << dp[N - 1][K] << endl;
  return 0;
}
