#include <bits/stdc++.h>
using namespace std;
void input() {}
long long int solve(long long int a[], long long int n, long long int k) {
  long long int dp[n + 1][k + 1];
  dp[0][0] = 1;
  for (long long int i = 0; i < n + 1; i++) {
    for (long long int j = 0; j < k + 1; j++) {
      if (i == 0) {
        dp[i][j] = 1;
      } else if (j == 0) {
        dp[i][j] = 1;
      } else {
        if (a[i - 1] >= j) {
          dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
          dp[i][j] %= 1000000007;
        } else {
          dp[i][j] = (dp[i - 1][j] % 1000000007 -
                      dp[i - 1][j - a[i - 1] - 1] % 1000000007 + 1000000007) %
                         1000000007 +
                     dp[i][j - 1] % 1000000007;
          dp[i][j] %= 1000000007;
        }
      }
    }
  }
  return dp[n][k] - dp[n][k - 1];
}
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];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  ;
  cout << solve(a, n, k);
}
