#include <bits/stdc++.h>
using namespace std;
template <class Read>
void in(Read &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f |= (ch == '-');
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
const int M = 1000000007;
int n, k;
long long a[100005], f[1000005], sum[100005];
int main() {
  in(n);
  in(k);
  for (int i = 1; i <= n; i++) in(a[i]);
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    sum[0] = 0;
    for (int j = 1; j <= k + 1; j++) sum[j] = (sum[j - 1] + f[j - 1]) % M;
    for (int j = 1; j <= k; j++) {
      int r = j, l = max(j - a[i], 0ll);
      f[j] = (f[j] + sum[r] - sum[l - 1]) % M;
    }
  }
  printf("%d\n", f[k]);
  return 0;
}
