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