#include <bits/stdc++.h>
using namespace std;
int p = 1e9 + 7;
int N;
int dp[100008];
int main() {
  int K;
  scanf("%d%d", &N, &K);
  {
    int a;
    scanf("%d", &a);
    for (int k = 0; k <= a; ++k) {
      dp[k] = 1;
    }
  }
  for (int n = 2; n < N; ++n) {
    int sum = 0;
    for (int k = 0; k <= K; ++k) {
      sum += dp[k];
      if (p <= sum) sum -= p;
      dp[k] = sum;
    }
    int a;
    scanf("%d", &a);
    for (int k = K; a < k; --k) {
      int sum = p + dp[k] - dp[k - a - 1];
      if (p <= sum) sum -= p;
      dp[k] = sum;
    }
  }
  if (2 <= N) {
    int sum = 0;
    for (int k = 0; k <= K; ++k) {
      sum += dp[k];
      if (p <= sum) sum -= p;
      dp[k] = sum;
    }
    int a;
    scanf("%d", &a);
    printf("%d\n", K == a ? dp[K] : p + dp[K] - dp[K - a - 1]);
  } else {
    printf("%d\n", dp[K]);
  }
  return 0;
}
