#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<vector<long long>> dp(N, vector<long long>(K + 1, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= K; j++) {
      if (i == 0 and j <= a[0]) dp[i][j] = 1;
      if (j == 0) dp[i][j] = 1;
    }
  }
  for (int j = 1; j <= K; j++) {
    dp[0][j] += dp[0][j - 1];
  }
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      int x = 0;
      if (j <= a[i])
        x = dp[i - 1][j] % 1000000007;
      else
        x = (dp[i - 1][j] % 1000000007 - dp[i - 1][j - a[i] - 1] % 1000000007) %
            1000000007;
      dp[i][j] = (dp[i][j - 1] % 1000000007 + x % 1000000007) % 1000000007;
    }
  }
  cout << (dp[N - 1][K] % 1000000007 - dp[N - 1][K - 1] % 1000000007) %
              1000000007;
}
