#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int p = 1e9 + 7;
void solverecursive() {
  int n, k;
  cin >> n >> k;
  vector<int> seq(n);
  for (auto &x : seq) {
    cin >> x;
  }
  vector<vector<int>> dp(n + 1, vector<int>(k + 1, -1));
  dp[0] = vector<int>(k + 1, 0);
  dp[0][0] = 1;
  function<int(int, int)> solve = [&](int i, int j) {
    if (j > k) {
      return 0;
    }
    if (j < 0) {
      j = 0;
    }
    if (~dp[i][j]) {
      return dp[i][j];
    }
    dp[i][j] =
        solve(i, j + 1) + solve(i - 1, j - seq[i - 1]) - solve(i - 1, j + 1);
    dp[i][j] >= p ? dp[i][j] -= p : dp[i][j];
    dp[i][j] < 0 ? dp[i][j] += p : dp[i][j];
    return dp[i][j];
  };
  cout << solve(n, k);
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> seq(n);
  for (auto &x : seq) {
    cin >> x;
  }
  vector<int> dp(k + 2);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = k, l = 0, r = 0; j >= 0; --j) {
      l = r;
      r = dp[j];
      dp[j] = dp[j + 1] + dp[max(0, j - seq[i])] - l;
      dp[j] >= p ? dp[j] -= p : dp[j];
      dp[j] < 0 ? dp[j] += p : dp[j];
    }
  }
  cout << dp[k] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solverecursive();
}
