#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long sz = 3e3 + 2;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
long long power(long long n, long long k, long long m) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans = (ans * n) % m;
    k /= 2;
    n = (n * n) % m;
  }
  return ans;
}
void solver() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n + 1, -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 < n + 1; i++) {
    for (long long j = 0; j < k + 1; j++) dp[i][j] = 0;
  }
  long long ans = 0;
  dp[0][0] = 1;
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 0; j < k + 1; j++) {
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }
      dp[i][j] = dp[i][j - 1] + dp[i - 1][j] -
                 ((j - 1 >= a[i]) ? dp[i - 1][j - 1 - a[i]] : 0);
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][k] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  for (long long i = 1; i < T + 1; i++) {
    clock_t z = clock();
    solver();
    fprintf(stderr, "Total Time: %.3f\n",
            (double)(clock() - z) / CLOCKS_PER_SEC),
        fflush(stderr);
  }
  return 0;
}
