#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  long long n, k;
  std::cin >> n >> k;
  long long arr[n];
  for (int i = 0; i < n; ++i) {
    std::cin >> arr[i];
  }
  long long dp[n + 1][k + 1];
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= k; i++) {
    dp[1][i] = (arr[0] < i) ? 0 : 1;
  }
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j - arr[i - 1] <= 0) {
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
        dp[i][j] = (dp[i][j] + mod) % mod;
      } else {
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - arr[i - 1]];
        dp[i][j] = (dp[i][j] + mod) % mod;
      }
    }
  }
  cout << dp[n][k];
  return 0;
}
