#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  vector<int> dp(k + 1);
  dp[0] = 1;
  vector<int> presum(k + 1, 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      int pos = max(0, j - arr[i]);
      if (pos > 0) {
        dp[j] = (presum[j] - presum[pos - 1]) % 1000000007;
      }
      if (pos == 0) {
        dp[j] = (presum[j]) % 1000000007;
      }
    }
    presum[0] = dp[0];
    for (int j = 1; j <= k; j++) {
      presum[j] = (presum[j - 1] + dp[j]) % 1000000007;
    }
  }
  cout << dp[k] << "\n";
}
