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