#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 2, 0));
  for (int i = 0; i < (n + 1); i++) dp[i][1] = 1;
  for (int i = 0; i < (n); i++) {
    int m = a[i];
    for (int j = 0; j < (k + 1); j++) {
      dp[i][j + 1] += dp[i][j];
      dp[i][j + 1] %= MOD;
    }
    for (int j = 1; j < k + 1; j++) {
      dp[i + 1][j + 1] = dp[i][j + 1] - dp[i][max(j - m, 0)];
      dp[i + 1][j + 1] %= MOD;
    }
  }
  cout << dp[n][k + 1] << endl;
}
