#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
struct edge {
  int to, cost;
};
long long n, k;
vector<long long> a;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  long long dp[n + 1][k + 1];
  for (int i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    a.push_back(temp);
  }
  for (int i = 0; i <= k; i++) {
    dp[0][i] = 0;
  }
  dp[0][0] = 1;
  long long sum[k + 2];
  for (int i = 1; i <= n; i++) {
    sum[0] = dp[i - 1][0];
    for (int j = 0; j <= k; j++) {
      if (j > 0) {
        sum[j] = sum[j - 1] + dp[i - 1][j];
        sum[j] %= MOD;
      }
      if (a[i - 1] >= j)
        dp[i][j] = sum[j];
      else {
        dp[i][j] = sum[j] - sum[j - a[i - 1] - 1];
      }
    }
  }
  cout << dp[n][k] << "\n";
}
