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