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