#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j;
  cin >> n >> k;
  int a[n], pre[n];
  cin >> a[0];
  pre[0] = a[0];
  for (i = 1; i < n; i++) {
    cin >> a[i];
    pre[i] = a[i] + pre[i - 1];
  }
  long long int dp[n][k + 1];
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < n; i++) {
    long long int sum[k + 1];
    if (i != 0) {
      sum[0] = dp[i - 1][0];
      for (j = 1; j <= k; j++)
        sum[j] = (dp[i - 1][j] + sum[j - 1]) % 1000000007;
    }
    for (j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = 1;
      else if (j > pre[i])
        dp[i][j] = 0;
      else if (i == 0)
        dp[i][j] = 1;
      else {
        long long int k = (j > a[i]) ? sum[j - a[i] - 1] : 0;
        dp[i][j] = sum[j] - k;
      }
    }
  }
  cout << dp[n - 1][k];
}
