#include <bits/stdc++.h>
using namespace std;
const long long MD = 1000000007;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n + 1);
  for (long long i = 1; i <= n; i++) cin >> a[i];
  vector<vector<long long> > dp(n + 1);
  for (auto &v : dp) v.resize(k + 1);
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long c = 0; c <= a[i]; c++) {
      dp[i][a[i]] += dp[i - 1][c] % MD;
      dp[i][a[i]] %= MD;
    }
    for (long long j = a[i] + 1; j <= k; j++) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - a[i] - 1]) % MD;
      dp[i][j] %= MD;
    }
    dp[i][0] = dp[i - 1][0];
    for (long long j = 1; j < a[i]; j++) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MD;
      dp[i][j] %= MD;
    }
  }
  cout << dp[n][k] % MD << "\n";
  return 0;
}
