#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 1e5 + 50;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<vector<long long> > dp(k + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i <= k; i++) {
    dp[i][0] = 1;
  }
  for (int j = 1; j <= n; j++) {
    for (int i = 0; i <= k; i++) {
      dp[i][j] = dp[i][j - 1];
      if ((i - v[j - 1]) > 0) {
        dp[i][j] -= dp[i - v[j - 1] - 1][j - 1];
      }
      dp[i][j] %= 1000000007;
      dp[i][j] += 1000000007;
      dp[i][j] %= 1000000007;
      if (i > 0) dp[i][j] += dp[i - 1][j];
      dp[i][j] %= 1000000007;
    }
  }
  cout << (dp[k][n] - dp[k - 1][n]);
}
