#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n + 1], dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i < n + 1; i++) cin >> a[i], dp[i][0] = 1;
  dp[0][0] = 1;
  for (int i = 1; i < n + 1; i++) {
    for (long long int j = 1; j <= k; j++) {
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;
      if (j > a[i])
        dp[i][j] = (dp[i][j] - dp[i - 1][j - a[i] - 1]) % 1000000007;
      if (dp[i][j] < 0) dp[i][j] = 0;
    }
  }
  cout << dp[n][k];
}
