#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto& v : a) {
    cin >> v;
  }
  vector<vector<ll>> dp(n, vector<ll>(k + 1, 0));
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 0; i < a[0] + 1; i++) {
    dp[0][i] = 1;
  }
  int limit = a[0];
  for (int i = 1; i < n; i++) {
    limit += a[i];
    for (int j = 1; j < k + 1; j++) {
      if (j > min(limit, k)) {
        break;
      }
      dp[i][j] += dp[i][j - 1];
      dp[i][j] += dp[i - 1][j];
      if (j - a[i] > 0) {
        dp[i][j] -= dp[i - 1][j - a[i - 1]];
      }
      dp[i][j] %= MOD;
    }
  }
  cout << dp[n - 1][k] << "\n";
  return 0;
}
