#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1e9;
const long long LINF = (long long)1e18;
const double EPS = 1e-7;
const int MAS = 3 * 1e5 + 10;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int LOG = 19;
const int ar = 1e5 + 100;
const int MAX = 1e6 + 1e2;
int dp[ar];
void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void sub(int &a, int b) {
  a -= b;
  if (a < MOD) a += MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  dp[0] = 1;
  for (int i = (0); i < (n); i++) {
    int x;
    cin >> x;
    vector<int> fake(k + 1);
    for (int sum = (k + 1) - 1; sum >= (0); sum--) {
      int now = dp[sum];
      int l = sum + 1;
      int r = sum + min(x, k - sum);
      if (l <= r) {
        add(fake[l], now);
        if (r + 1 <= k) {
          sub(fake[r + 1], now);
        }
      }
    }
    int magic = 0;
    for (int i = (0); i < (k + 1); i++) {
      add(magic, fake[i]);
      add(dp[i], magic);
    }
  }
  cout << dp[k];
}
