#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  int N, K;
  std::cin >> N >> K;
  vector<vector<int>> dp = vector<vector<int>>(N + 1, vector<int>(K + 1, 0));
  vector<vector<int>> prefix = dp;
  prefix[0] = vector<int>(K + 1, 1);
  for (int i = 1; i <= N; ++i) {
    int kid;
    cin >> kid;
    for (int sum = 0; sum <= K; ++sum) {
      int R = min(kid, sum);
      dp[i][sum] = sub(prefix[i - 1][sum],
                       (sum - R > 0 ? prefix[i - 1][sum - R - 1] : 0));
      prefix[i][sum] = (dp[i][sum], (sum > 0 ? prefix[i][sum - 1] : 0)) % MOD;
    }
  }
  std::cout << dp[N][K];
  return 0;
}
