#include <bits/stdc++.h>
using namespace std;
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const long long inf = 1e18;
long long dp[N], tree[4 * N], lazy[4 * N];
long long add(long long a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a < 0) a += MOD;
  return a;
}
void propagate(int node, int start, int end) {
  if (!lazy[node]) return;
  tree[node] += (long long)(end - start + 1) * lazy[node];
  tree[node] = add(tree[node], 0);
  if (start != end) {
    lazy[node * 2] = add(lazy[node * 2], lazy[node]);
    lazy[node * 2 + 1] = add(lazy[node * 2 + 1], lazy[node]);
  }
  lazy[node] = 0;
}
void update(int node, int start, int end, int l, int r, int v) {
  propagate(node, start, end);
  if (start > r || end < l) return;
  if (start >= l && end <= r) {
    lazy[node] = v;
    propagate(node, start, end);
    return;
  }
  int mid = (start + end) / 2;
  update(node * 2, start, mid, l, r, v);
  update(node * 2 + 1, mid + 1, end, l, r, v);
  tree[node] = add(tree[node * 2], tree[node * 2 + 1]);
}
long long query(int node, int start, int end, int l, int r) {
  propagate(node, start, end);
  if (start > r || end < l) return 0;
  if (start >= l && end <= r) return tree[node];
  int mid = (start + end) / 2;
  long long p1 = query(node * 2, start, mid, l, r);
  long long p2 = query(node * 2 + 1, mid + 1, end, l, r);
  p1 = add(p1, p2);
  return p1;
}
int main() {
  cout << fixed << setprecision(9), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  int n, k, x;
  cin >> n >> k;
  dp[0] = 1;
  update(1, 0, N, 0, 0, 1);
  for (int i = 0; i < n; ++i) {
    cin >> x;
    for (int j = k; j >= 0; --j) {
      int L = 1 + j, R = min(x, k - j) + j, val = query(1, 0, N, j, j);
      if (L <= R && val) update(1, 0, N, L, R, val);
    }
  }
  cout << query(1, 0, N, k, k) << '\n';
  return 0;
}
