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