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