#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "; ";
  err(++it, args...);
}
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long ceil2(long long a, long long b) {
  long long c = a / b;
  if (c * b < a) c++;
  return c;
}
int32_t main() {
  c_p_c();
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i < n + 1; ++i) {
    cin >> a[i];
  }
  long long dp[n + 1][k + 1];
  for (long long i = 0; i < k + 1; ++i) {
    dp[0][i] = 0;
  }
  for (long long i = 0; i < n + 1; ++i) {
    dp[i][0] = 1;
  }
  long long psum[k + 1];
  for (long long i = 1; i < n + 1; ++i) {
    psum[0] = dp[i - 1][0] % 1000000007;
    for (long long j = 1; j < k + 1; ++j) {
      psum[j] =
          (psum[j - 1] % 1000000007 + dp[i - 1][j] % 1000000007) % 1000000007;
    }
    for (long long j = 1; j < k + 1; ++j) {
      dp[i][j] = 0;
      dp[i][j] = psum[j] -
                 (j - min(a[i], j) - 1 >= 0 ? psum[j - min(a[i], j) - 1] : 0);
    }
  }
  cout << dp[n][k];
  return 0;
}
