#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long mod = 1e9 + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n + 1);
  for (int z = 1; z <= n; z++) {
    cin >> arr[z];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  long long count = 0;
  for (int z = 1; z <= n; z++) {
    long long sum = 0;
    count += arr[z];
    for (int x = 0; x <= count && x <= k; x++) {
      if (x > arr[z])
        sum -= dp[z - 1][x - arr[z] - 1];
      else
        sum += dp[z - 1][x];
      if (sum < 0) sum += mod;
      dp[z][x] += sum;
      dp[z][x] %= mod;
      sum %= mod;
    }
  }
  cout << dp[n][k] << endl;
  cin >> n;
}
