#include <bits/stdc++.h>
using namespace std;
long long subsetSum(int start, vector<int>& candies, int sum, vector<int>& p,
                    vector<vector<long long>>& memo) {
  if (sum == 0) {
    return 1;
  } else if (sum < 0)
    return 0;
  long long n = 0;
  if (start >= candies.size()) return 0;
  if (memo[start][sum] != -1) return memo[start][sum];
  for (int j = candies[start]; j >= 0; j--) {
    p.push_back(j);
    n += subsetSum(start + 1, candies, sum - j, p, memo);
    p.pop_back();
  }
  memo[start][sum] = n;
  return n;
}
const long long MOD = 1e9 + 7;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> candies;
  for (int i = 0; i < N; i++) {
    int candy;
    cin >> candy;
    candies.push_back(candy);
  }
  vector<int> p;
  vector<vector<long long>> dp(candies.size(), vector<long long>(K + 1, 0));
  for (int i = 0; i < candies.size(); i++) dp[i][0] = 1;
  for (int i = 0; i < candies.size(); i++) {
    for (int j = 1; j <= K; j++) {
      if (i == 0) {
        dp[i][j] = j > candies[0] ? 0 : 1;
      } else
        dp[i][j] =
            (dp[i - 1][j] % MOD + dp[i][j - 1] % MOD -
             (j - candies[i] - 1 >= 0 ? dp[i - 1][j - candies[i] - 1] : 0) %
                 MOD) %
            MOD;
    }
  }
  cout << dp[candies.size() - 1][K] << endl;
  return 0;
}
