#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, k;
  cin >> n >> k;
  VLL a(n + 1);
  for (int i = (1); i < (int)(n + 1); ++i) cin >> a[i];
  VVI dp(n + 1, VI(k + 1, 0)), Sum(n + 1, VI(k + 1, 0));
  dp[0][0] = 1;
  LL candy = 0;
  for (int i = (1); i < (int)(n + 1); ++i) {
    candy += a[i];
    Sum[i - 1][0] = dp[i - 1][0];
    for (int j = (1); j < (int)(k + 1); ++j) {
      Sum[i - 1][j] = Sum[i - 1][j - 1] + dp[i - 1][j];
      Sum[i - 1][j] %= MOD;
    }
    for (int j = 0; j < (int)(k + 1); ++j) {
      if (j > candy) break;
      dp[i][j] = Sum[i - 1][j];
      if (j - a[i] - 1 >= 0) dp[i][j] -= Sum[i - 1][j - a[i] - 1];
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
