#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int n, k;
int a[1000006];
int dp[100005][105];
void ReadInPut() {
  n = read();
  k = read();
  for (int i = (int)0; i <= (int)n - 1; i++) a[i] = read();
}
void Solve() {
  for (int i = (int)0; i <= (int)n - 1; i++) {
    dp[0][i] = 1;
    for (int j = (int)1; j <= (int)k; j++) {
      if (i != 0) {
        dp[j][i] = dp[j - 1][i];
        dp[j][i] += dp[j][i - 1];
        if (j >= a[i] + 1) dp[j][i] -= dp[j - a[i] - 1][i - 1];
        dp[j][i] %= 1000000007;
      } else {
        dp[j][i] = j <= a[i];
      }
    }
  }
  cout << dp[k][n - 1];
}
int main() {
  int sotest = 1;
  for (int i = 1; i <= sotest; i++) {
    ReadInPut();
    Solve();
  }
}
