#include <bits/stdc++.h>
void run(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  const int mod = 1000000007;
  int *dp = (int *)calloc(4 * (k + 1), sizeof(int)) + k;
  dp[(((0) & 1) * (2 * k + 1) + (0))] = 1;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j <= k; j++) {
      dp[(((i + 1) & 1) * (2 * k + 1) + (j))] =
          ((long long int)dp[(((i + 1) & 1) * (2 * k + 1) + (j - 1))] +
           dp[(((i)&1) * (2 * k + 1) + (j))] -
           dp[(((i)&1) * (2 * k + 1) + (j - 1 - a))] + mod) %
          mod;
    }
  }
  printf("%d\n", dp[(((n)&1) * (2 * k + 1) + (k))]);
}
int main(void) {
  run();
  return 0;
}
