#include <bits/stdc++.h>
using namespace std;
void run() {
  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];
  for (long long i = 0; i < k + 1; i++)
    for (long long j = 0; j <= n; j++) dp[j][i] = 0;
  for (long long i = 0; i < k + 1; i++) dp[0][i] = 1;
  for (long long i = 1; i <= n; i++) {
    long long sm = 0;
    for (long long j = 0; j <= k; j++) {
      sm = (dp[i - 1][j] - (j - a[i] - 1 >= 0 ? dp[i - 1][j - a[i] - 1] : 0) +
            1000000007 + sm) %
           1000000007;
      dp[i][j] = (dp[i][j] + sm) % 1000000007;
    }
  }
  cout << (dp[n][k] - dp[n][k - 1] + 1000000007) % 1000000007;
}
int main() {
  run();
  return 0;
}
