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