#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 77;
const long long mod = (int)1e9 + 7;
const long long inf = (int)1e9 + 77;
int main() {
  long long n, k, a[N];
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%lld", a + i);
  vector<long long> dp(k + 1, 0);
  vector<long long> sum(k + 1, 0);
  dp[0] = 1, sum[0] = 1;
  for (int i = 1; i <= k; i++) sum[i] = sum[i - 1] + dp[i];
  for (int child = 1; child <= n; child++) {
    vector<long long> new_sum(k + 1, 0);
    new_sum[0] = 1;
    for (int candies = 1; candies <= k; candies++) {
      int left = candies - a[child] - 1;
      dp[candies] = sum[candies] - (left < 0 ? 0 : sum[left]);
      new_sum[candies] = new_sum[candies - 1] + dp[candies];
      dp[candies] %= mod;
      new_sum[candies] %= mod;
    }
    sum = new_sum;
  }
  printf("%lld", dp[k]);
  return 0;
}
