#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> a(n);
  for (int &i : a) scanf("%d", &i);
  vector<int> dp(k + 5);
  dp[0] = 1;
  vector<int> temp(k + 5);
  vector<int> sm(k + 5, 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[j] = (sm[j] - (j - a[i] > 0 ? sm[j - a[i] - 1] : 0)) % 1000000007;
    }
    sm[0] = dp[0];
    for (int j = 1; j <= k; j++) {
      sm[j] = (sm[j - 1] + dp[j]) % 1000000007;
    }
  }
  printf("%d\n", dp[k]);
}
