#include <bits/stdc++.h>
long long mod = pow(10, 9) + 7;
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long prev[k + 1];
  long long curr[k + 1];
  prev[0] = 1;
  for (int i = 1; i <= k; i++) {
    if (i <= a[0])
      prev[i] = (prev[i - 1] % mod + 1) % mod;
    else
      prev[i] = prev[i - 1] % mod;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      int startind = max((long long)0, j - a[i]);
      int endind = j;
      curr[j] = prev[endind] % mod;
      if (startind > 0)
        curr[j] = (curr[j] % mod - prev[startind - 1] % mod + mod) % mod;
    }
    prev[0] = curr[0] % mod;
    for (int j = 1; j <= k; j++)
      prev[j] = (prev[j - 1] % mod + curr[j] % mod) % mod;
  }
  cout << curr[k];
  return 0;
}
