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