#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long dp[n + 1][k + 1];
  long long prefix[n + 1][k + 1];
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (j == 0 || i == 0) {
        dp[i][j] = 1;
        prefix[i][j] = 1;
      } else {
        dp[i][j] = prefix[i - 1][j] -
                   ((j - a[i] - 1 >= 0) ? prefix[i - 1][j - a[i] - 1] : 0);
        dp[i][j] %= 1000000007;
        prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % 1000000007;
      }
    }
  }
  cout << dp[n][k];
}
