#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int add_self(int &a, int b) {
  a = a + b;
  if (a > mod) {
    a -= mod;
  }
}
int sub_self(int &a, int b) {
  a = a - b;
  if (a < mod) {
    a += mod;
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int upto;
    cin >> upto;
    vector<int> diff(k + 1);
    for (int j = k - 1; j >= 0; j--) {
      int tmp = dp[j];
      int L = j + 1;
      int R = j + upto;
      if (L <= R) {
        add_self(diff[L], tmp);
        if (R + 1 <= k) {
          sub_self(diff[R + 1], tmp);
        }
      }
    }
    int prefix = 0;
    for (int i = 0; i <= k; i++) {
      add_self(prefix, diff[i]);
      add_self(dp[i], prefix);
    }
  }
  cout << dp[k] << endl;
}
