#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
long long int N, M, K, H, W, L, R;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  vector<vector<long long int>> dp(2, vector<long long int>(K + 2));
  dp[1][0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> M;
    for (auto &j : dp[i & 1]) j = 0;
    for (int j = 0; j <= K; j++) {
      dp[i & 1][j] += dp[(i ^ 1) & 1][j];
      dp[i & 1][min(j + M, K) + 1] -= dp[(i ^ 1) & 1][j];
    }
    for (int j = 1; j <= K; j++) {
      dp[i & 1][j] += dp[i & 1][j - 1];
      dp[i & 1][j] %= MOD;
    }
  }
  cout << dp[(N ^ 1) & 1][K] << endl;
}
