#include <bits/stdc++.h>
using namespace std;
void add(int &a, int b) {
  a += b;
  if (a >= b) {
    a -= 1000000007;
  }
}
void sub(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += 1000000007;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int> > dp(n + 1, vector<int>(k + 1, 0));
  vector<vector<int> > pre(n + 1, vector<int>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      int l = j;
      int r = min(k, j + a[i - 1]);
      pre[i - 1][l] = (pre[i - 1][l] + dp[i - 1][j]) % 1000000007;
      if (r + 1 > k) {
        continue;
      }
      pre[i - 1][r + 1] = (pre[i - 1][r + 1] - dp[i - 1][j]) % 1000000007;
    }
    int sum = 0;
    for (int j = 0; j <= k; j++) {
      sum = (sum + pre[i - 1][j]) % 1000000007;
      dp[i][j] = (dp[i][j] + sum) % 1000000007;
    }
    cout << endl;
  }
  cout << dp[n][k];
}
