#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> dp(k + 1), new_dp(k + 1);
  dp[0] = 1;
  for (long long i = 1; i < n + 1; i++) {
    sum = 0;
    for (long long j = 0; j < k + 1; j++) {
      if (a[i - 1] >= j) {
        sum += (dp[j] + inf) % inf;
        sum = (sum + inf) % inf;
        new_dp[j] = sum;
      } else {
        sum -= (dp[j - a[i - 1] - 1] + inf);
        sum = (sum + inf) % inf;
        new_dp[j] = sum;
      }
    }
    swap(dp, new_dp);
  }
  cout << (dp[k] + inf) % inf;
}
