#include <bits/stdc++.h>
using namespace std;
vector<bool> is_prime(10000, 1);
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void sieve() {
  is_prime[0] = is_prime[1] = 0;
  for (int i = 2; i * i <= 10000; i++)
    if (is_prime[i])
      for (long long j = i * i; (i > 0 ? j < 10000 : j > 10000) and i != 0;
           j += i)
        is_prime[j] = 0;
}
bool cmp(const pair<long long, long long> &c,
         const pair<long long, long long> &b) {
  return c.first > b.first;
}
const long long man = 1e6;
vector<long long> edges[man];
vector<long long> visited(man, -1);
long long ans = 0;
void dfs(long long a, long long dist[]) {
  visited[a] = 1;
  if (edges[a].size() == 1) {
    if (visited[edges[a][0]] == 1) {
    } else {
      dist[edges[a][0]] = dist[a] + 1;
      dfs(edges[a][0], dist);
    }
  }
  for (auto v1 : edges[a]) {
    if (visited[v1] == -1) {
      dist[v1] = dist[a] + 1;
      dfs(v1, dist);
    }
  }
}
int main() {
  long long int i, j, k, o, n, m;
  cin >> n >> k;
  long long dp[k + 1];
  long long mod = 1e9 + 7;
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    vector<long long> fake(k + 1);
    for (long long used = k; used >= 0; used--) {
      long long tmp = dp[used];
      long long l = used + 1;
      long long r = used + min(k - used, a[i]);
      if (l <= r) {
        fake[l] = fake[l] + tmp % mod;
        if (r + 1 <= k) {
          fake[r + 1] = fake[r + 1] - tmp % mod;
        }
      }
    }
    long long prefix = 0;
    for (j = 0; j <= k; j++) {
      prefix = prefix % mod + fake[j] % mod;
      dp[j] = dp[j] % mod + prefix % mod;
    }
  }
  cout << dp[k] % mod << '\n';
}
