#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
void mod(int &x) { x %= MOD; }
void mod(long long &x) { x %= (long long)MOD; }
const int mxN = 1e5 + 5;
long long tree[mxN * 4];
long long lz[mxN * 4];
void init() {
  memset(tree, 0, sizeof(tree));
  memset(lz, 0, sizeof(lz));
}
void build(int node, int l, int r) {
  init();
  if (l == r) {
    tree[node] = 0;
    return;
  }
  int mid = (l + r) / 2;
  build(node * 2, l, mid);
  build(node * 2 + 1, mid + 1, r);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
  mod(tree[node]);
}
void update(int n, int index, int l, int r, int node) {
  if (l == r) {
    tree[node] = n;
    return;
  }
  int mid = (l + r) / 2;
  if (index <= mid) {
    update(n, index, l, mid, node * 2);
  } else {
    update(n, index, mid + 1, r, node * 2 + 1);
  }
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
  mod(tree[node]);
}
void push_down(int node, int l, int r) {
  if (lz[node]) {
    int mid = (l + r) / 2;
    lz[node * 2] += lz[node];
    mod(lz[node * 2]);
    lz[node * 2 + 1] += lz[node];
    mod(lz[node * 2 + 1]);
    tree[node * 2] += 1LL * (mid - l + 1) * lz[node];
    mod(tree[node * 2]);
    tree[node * 2 + 1] += 1LL * (r - mid) * lz[node];
    mod(tree[node * 2 + 1]);
    lz[node] = 0;
  }
}
void update_range(int node, int l, int r, int L, int R, int add) {
  if (l <= L && r >= R) {
    lz[node] += 1LL * add;
    tree[node] += 1LL * (R - L + 1) * add;
    mod(tree[node]);
    return;
  }
  push_down(node, L, R);
  int mid = (L + R) / 2;
  if (mid >= l) update_range(node * 2, l, r, L, mid, add);
  if (mid < r) update_range(node * 2 + 1, l, r, mid + 1, R, add);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
  mod(tree[node]);
}
long long query_range(int node, int L, int R, int l, int r) {
  if (l <= L && r >= R) return tree[node];
  push_down(node, L, R);
  int mid = (L + R) / 2;
  long long sum = 0;
  if (mid >= l) sum += query_range(node * 2, L, mid, l, r);
  mod(sum);
  if (mid < r) sum += query_range(node * 2 + 1, mid + 1, R, l, r);
  mod(sum);
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  update(1, 0 + 1, 1, k + 1, 1);
  for (register int child = 0; child < n; ++child) {
    int up_to;
    cin >> up_to;
    for (register int used = k; used >= 0; --used) {
      int L = used + 1;
      int R = used + min(k - used, up_to);
      if (L > R) continue;
      int tmp = query_range(1, 1, k + 1, used + 1, used + 1);
      update_range(1, L + 1, R + 1, 1, k + 1, tmp);
    }
  }
  cout << query_range(1, 1, k + 1, k + 1, k + 1) << endl;
  return 0;
}
