#include <bits/stdc++.h>
const long long mod = 1000 * 1000 * 1000 + 7;
using namespace std;
inline long long add(long long a, long long b) {
  a += b;
  a %= mod;
  return a;
}
inline long long sub(long long a, long long b) {
  a -= b;
  a %= mod;
  return a;
}
int32_t main() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i < (long long)(n + 1); ++i) {
    cin >> a[i];
  }
  long long d[n + 1][k + 1];
  long long p[n + 1][k + 1];
  memset(d, 0, sizeof(long long) * (n + 1) * (k + 1));
  memset(p, 0, sizeof(long long) * (n + 1) * (k + 1));
  for (long long i = 0; i < (long long)(a[1] + 1); ++i) {
    d[1][i] = 1;
  }
  p[1][0] = d[1][0];
  for (long long i = 1; i < (long long)(k + 1); ++i) {
    p[1][i] = add(p[1][i - 1], d[1][i]);
  }
  for (long long i = 2; i < (long long)(n + 1); ++i) {
    for (long long j = 0; j < (long long)(k + 1); ++j) {
      if (j - a[i] > 0) {
        d[i][j] = sub(p[i - 1][j], p[i - 1][j - a[i] - 1]);
      } else {
        d[i][j] = p[i - 1][j];
      }
      if (j > 0)
        p[i][j] = add(p[i][j - 1], d[i][j]);
      else
        p[i][j] = d[i][j];
    }
  }
  cout << d[n][k];
  return 0;
}
