#include <bits/stdc++.h>
using namespace std;
const long long int mod = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  long long int a[n + 1], dp[n + 1][k + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[0][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    vector<int> sum(k + 1);
    sum[0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++) {
      sum[j] = (sum[j - 1] + dp[i - 1][j]) % mod;
    }
    for (int j = 0; j <= k; j++) {
      if (j <= a[i]) {
        dp[i][j] = sum[j];
      } else {
        dp[i][j] = (sum[j] - sum[j - a[i] - 1] + mod) % mod;
      }
    }
    sum.clear();
  }
  cout << dp[n][k] << "\n";
}
