#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
template <class T>
void chmax(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void chmin(T& a, const T& b) {
  a = min(a, b);
}
template <class T>
T** arr2D(int n, int m, T init) {
  T** mat = new T*[n];
  for (long long i = (0); (0) < (n) ? i < (n) : i > (n);
       (0) < (n) ? i += 1 : i -= 1) {
    mat[i] = new T[m];
    for (long long j = (0); (0) < (m) ? j < (m) : j > (m);
         (0) < (m) ? j += 1 : j -= 1) {
      mat[i][j] = init;
    }
  }
  return mat;
}
template <class T>
void initialise(T** mat, T init, int n, int m) {
  for (long long i = (0); (0) < (n) ? i < (n) : i > (n);
       (0) < (n) ? i += 1 : i -= 1) {
    for (long long j = (0); (0) < (m) ? j < (m) : j > (m);
         (0) < (m) ? j += 1 : j -= 1) {
      mat[i][j] = init;
    }
  }
}
template <class T>
void destroy(T** mat, int n, int m) {
  for (long long i = (0); (0) < (n) ? i < (n) : i > (n);
       (0) < (n) ? i += 1 : i -= 1) {
    delete[] mat[i];
  }
  delete[] mat;
}
const int MOD = 1000000007;
long long fastpowMOD(long long a, long long p, long long MOD) {
  if (p == 0) return 1;
  long long z = fastpowMOD(a, p / 2, MOD);
  z = (z * z) % MOD;
  if (p % 2) z = (z * a) % MOD;
  return z;
}
long long ways[2][100100];
void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> arr(N);
  for (long long i = (0); (0) < (N) ? i < (N) : i > (N);
       (0) < (N) ? i += 1 : i -= 1)
    cin >> arr[i];
  int t = 1;
  ways[0][0] = 1;
  for (long long i = (0); (0) < (N) ? i < (N) : i > (N);
       (0) < (N) ? i += 1 : i -= 1) {
    for (long long k = (0); (0) < (K + 1) ? k < (K + 1) : k > (K + 1);
         (0) < (K + 1) ? k += 1 : k -= 1) {
      long long ans;
      if (k == 0) {
        ans = 1;
      } else {
        ans = ways[t ^ 1][k] + ways[t][k - 1];
        if (k - arr[i] - 1 >= 0) {
          ans -= ways[t ^ 1][k - arr[i] - 1];
        }
      }
      ways[t][k] = ans % MOD;
    }
    t ^= 1;
  }
  cout << ways[t ^ 1][K] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
