#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
vector<long long> v;
int main() {
  cin >> n >> k;
  v = vector<long long>(n + 1);
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  for (long long i = 1; i <= n; i++) cin >> v[i];
  long long ans;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (i == 0 && j == 0)
        dp[i][j] = 1;
      else if (i > 0) {
        long long minind = min(v[i], j);
        long long sum = 0;
        if (minind < j)
          sum = dp[i - 1][j] - dp[i - 1][j - minind - 1];
        else
          sum = dp[i - 1][j];
        dp[i][j] = sum % 1000000007;
      }
      if (i == n && j == k) ans = dp[i][j];
    }
    for (long long j = 1; j <= k; j++)
      dp[i][j] = (dp[i][j] + dp[i][j - 1]) % 1000000007;
  }
  cout << ans << endl;
}
