#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000004;
const long long INF = 1e18L + 5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  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 i = 1; i < k + 1; ++i) dp[0][i] = 0;
  for (long long i = 1; i < n + 1; ++i) {
    vector<long long> sum(k + 1, 0);
    sum[0] = dp[i - 1][0];
    for (long long j = 1; j < k + 1; ++j)
      sum[j] = (sum[j - 1] + dp[i - 1][j]) % 1000000007;
    for (long long j = 0; j < k + 1; ++j) {
      if (j <= a[i]) {
        dp[i][j] = sum[j];
      } else {
        long long s = (j - a[i] - 1);
        dp[i][j] = (sum[j] - sum[s]) % 1000000007;
      }
    }
    sum.clear();
  }
  cout << dp[n][k] % 1000000007 << "\n";
}
