#include <bits/stdc++.h>
using namespace std;
int n, k, dp[100055], ar[100055], pre[100055];
const int mod = 1e9 + 7;
void mod_add(int &a, int b) {
  a += b;
  if (a > mod) a -= mod;
  if (a < 0) a += mod;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &ar[i]);
  }
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int used = k; used >= 0; --used) {
      int L = used + 1;
      int R = used + min(ar[i], k - used);
      mod_add(pre[L], dp[used]);
      mod_add(pre[R + 1], -dp[used]);
    }
    int ss = 0;
    for (int x = 0; x <= k; ++x) {
      mod_add(ss, pre[x]);
      mod_add(dp[x], ss);
      pre[x] = 0;
    }
  }
  cout << dp[k];
  return 0;
}
