#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
const long long MOD = 1e9 + 7;
using ll = long long;
void add_self(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}
void sub_self(int &a, int b) {
  a -= b;
  if (a <= 0) {
    a += MOD;
  }
}
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  int a[K];
  vector<int> dp(K + 1);
  dp[0] = 1;
  for (int child = 0; child < N; ++child) {
    int up_to;
    cin >> up_to;
    vector<int> fake(K + 1);
    for (int used = K; used >= 0; --used) {
      int l = used + 1;
      int r = used + min(up_to, K - used);
      add_self(fake[l], dp[used]);
      sub_self(fake[r + 1], dp[used]);
    }
    int prefix_sum = 0;
    for (int i = 0; i <= K; ++i) {
      add_self(prefix_sum, fake[i]);
      add_self(dp[i], prefix_sum);
    }
  }
  printf("%d\n", dp[K]);
}
