#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, i, x, j, sum;
  cin >> n >> k;
  int a[n + 1];
  int dp[n + 1][k + 1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (i = 0; i <= k; i++) {
    if (i <= a[1]) {
      dp[1][i] = 1;
    } else {
      dp[1][i] = 0;
    }
  }
  int sumarr[k + 1];
  for (i = 2; i <= n; i++) {
    sum = 0;
    for (j = 0; j <= k; j++) {
      if (j - a[i] <= 0) {
        sum = (sum + dp[i - 1][j]) % 1000000007;
      } else {
        sum = (sum + dp[i - 1][j] - dp[i - 1][j - a[i] - 1]) % 1000000007;
      }
      sumarr[j] = sum;
    }
    for (j = 1; j <= k; j++) {
      dp[i][j] = sumarr[j];
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
