#include <bits/stdc++.h>
using namespace std;
int N;
int K;
long long ways[1000005];
int a;
int sum;
int main() {
  cin >> N >> K;
  memset(ways, 0, sizeof(ways));
  ways[K] = 1;
  for (int i = 0; i < N; i++) {
    cin >> a;
    sum = 0;
    for (int j = 1; j <= min(a, K); j++) {
      sum += ways[j];
      sum %= 1000000007;
    }
    for (int j = 0; j <= K; j++) {
      ways[j] = (ways[j] + sum) % 1000000007;
      sum -= ways[j + 1];
      if (j + a + 1 <= K) sum += ways[j + a + 1];
      sum = (sum + 1000000007) % 1000000007;
    }
  }
  cout << ways[0] << endl;
}
