#include <bits/stdc++.h>
using namespace std;
long long num_of_ways(vector<long long>& capacity, long long n, long long k) {
  vector<vector<long long>> dp(n + 2, vector<long long>(k + 2));
  for (long long j = 0; j <= k; j++) {
    if (j > capacity[1])
      dp[1][j] = 0;
    else
      dp[1][j] = 1;
  }
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = dp[i - 1][j] % 1000000007;
      } else if (j - 1 - capacity[i] >= 0) {
        dp[i][j] =
            (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1 - capacity[i]]) %
            1000000007;
      } else {
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % 1000000007;
      }
    }
  }
  return dp[n][k];
}
int main() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> capacity(n + 1);
  for (long long i = 1; i <= n; i++) {
    long long d;
    cin >> d;
    capacity[i] = d;
  }
  cout << num_of_ways(capacity, n, k);
  return 0;
}
