#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int add(int a, int b) {
  if (a + b >= mod) return a + b - mod;
  return a + b;
}
int sub(int a, int b) {
  if (a > b) return a - b;
  return a - b + mod;
}
int mul(int a, int b) { return 1LL * a * b % mod; }
int const N = 1e5 + 10;
void show(vector<int> a) {
  for (auto b : a) cout << b << " ";
  cout << endl;
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 5, 0);
  dp[0] = 1;
  for (int x = 0; x < n; x++) {
    vector<int> sum(k + 5, 0);
    sum[0] = dp[0];
    for (int y = 1; y <= k + 2; y++) sum[y] = add(sum[y - 1], dp[y]);
    int a1;
    cin >> a1;
    for (int y = 1; y <= k; y++) {
      int a = 0;
      if (y > a1)
        a = sub(sum[y], sum[y - a1 - 1]);
      else
        a = sum[y];
      dp[y] = a;
    }
  }
  if (k == 0) {
    cout << 1 << "\n";
    return;
  }
  cout << dp[k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
