#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long dp[n + 1][k + 1];
  long long sum[n + 1][k + 1];
  for (long long int children = 0; children <= n; ++children) {
    for (long long int candies = 0; candies <= k; ++candies) {
      if (candies == 0) {
        dp[children][candies] = 1;
        sum[children][candies] = 1;
      } else if (children == 0) {
        dp[children][candies] = 0;
        sum[children][candies] = 1;
      } else {
        dp[children][candies] =
            sum[children - 1][candies] -
            sum[children - 1][candies - min(candies, a[children - 1])];
        dp[children][candies] =
            (dp[children][candies] +
             dp[children - 1][candies - min(candies, a[children - 1])]) %
            mod;
        sum[children][candies] =
            (dp[children][candies] + sum[children][candies - 1]) % mod;
      }
    }
  }
  long long ans = dp[n][k];
  cout << ans << '\n';
  return 0;
}
