#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  long long dp[2][k + 5];
  dp[0][0] = 1;
  dp[1][0] = 0;
  for (int i = 1; i <= k; i++) {
    dp[0][i] = 0;
    dp[1][i] = 0;
  }
  long long pref[k + 5];
  for (int i = 0; i <= k; i++) pref[i] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      int x = max(-1, j - arr[i] - 1);
      dp[1][j] = pref[j] - (x >= 0 ? pref[x] : 0);
      dp[1][j] %= 1000000007;
    }
    for (int j = 0; j <= k; j++) {
      dp[0][j] = dp[1][j];
      if (j == 0)
        pref[j] = dp[0][j];
      else
        pref[j] = dp[0][j] + pref[j - 1];
      pref[j] %= 1000000007;
    }
  }
  printf("%lld", dp[0][k]);
}
