#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T vec) {
  for (auto d : vec) cout << d << ' ';
  cout << '\n';
}
template <typename T>
void print2D(T mat) {
  for (auto vec : mat) print(vec);
}
const long long int MOD = 1e9 + 7;
int n, k;
void mod(long long int& x) {
  if (x >= MOD) x -= MOD;
}
void solve(vector<int>& vec) {
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1, 0));
  dp[0][0] = 1;
  for (int child = 1; child <= n; child++) {
    for (int candies = 0; candies <= k; candies++) {
      if (candies == 0)
        dp[child][candies] = 1;
      else if (candies - vec[child] - 1 > 0) {
        dp[child][candies] = dp[child - 1][candies] + dp[child][candies - 1] -
                             dp[child - 1][candies - vec[child] - 1];
      } else {
        dp[child][candies] = dp[child - 1][candies] + dp[child][candies - 1];
      }
      mod(dp[child][candies]);
    }
  }
  cout << dp[n][k] << '\n';
}
int main() {
  cin >> n >> k;
  vector<int> A(n + 1);
  for (int i = 1; i <= n; i++) cin >> A[i];
  solve(A);
  return 0;
}
