#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  long long dp[n + 1][k + 1];
  dp[0][0] = 1;
  for (long long j = 1; j < k + 1; j++) {
    dp[0][j] = 0;
  }
  for (long long i = 1; i < n + 1; i++) {
    long long sum[k + 1];
    sum[0] = dp[i - 1][0];
    for (long long j = 1; j < k + 1; j++) {
      sum[j] = (sum[j - 1] + dp[i - 1][j]) % (long long)(1e9 + 7);
    }
    for (long long j = 0; j < k + 1; j++) {
      long long add = sum[j];
      long long subtract = min(j, a[i]);
      if (subtract != j) add -= sum[j - subtract - 1];
      dp[i][j] = add;
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
