#include <bits/stdc++.h>
using namespace std;
void init() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long &i : a) cin >> i;
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 1));
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (i == 0 or j == 0) continue;
      dp[i][j] = dp[i - 1][j];
      long long left = j - a[i - 1];
      if (left > 0)
        (dp[i][j] = dp[i][j - 1] + (dp[i - 1][j] - dp[i - 1][left - 1])) %=
            1000000007;
      else
        (dp[i][j] = dp[i][j - 1] + dp[i - 1][j]) %= 1000000007;
    }
  }
  cout << (dp[n][k] - dp[n][k - 1] + 1000000007) % 1000000007;
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  init();
  return 0;
}
