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