#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
vector<long long int>::iterator it1;
long long int gc(long long int a, long long int b) {
  if (b == 0) return a;
  return gc(b, a % b);
}
vector<bool> prime(100005, true);
vector<long long int> v;
void sieve(long long int n) {
  prime[1] = false;
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (prime[i] == true) v.push_back(i);
  }
}
bool comp(pair<long long int, long long int>& p1,
          pair<long long int, long long int>& p2) {
  return (p1.second < p2.second);
}
int BIT[1000];
void update(int x, int delta) {
  int n;
  for (; x <= n; x += x & -x) BIT[x] += delta;
}
int query(int x) {
  int sum = 0;
  for (; x > 0; x -= x & -x) sum += BIT[x];
  return sum;
}
vector<vector<long long int> > dp(30005, vector<long long int>(248, -1));
map<long long int, long long int> m;
long long int recur(long long int cur, long long int pre, long long int n) {
  if (cur > n) return 0;
  long long int len = cur - pre;
  if (dp[cur][len] != -1) return dp[cur][len];
  long long int temp = 0;
  temp += m[cur];
  if (len == 1)
    temp += max(recur(cur + len - 1, cur, n), recur(cur + len + 1, cur, n));
  else
    temp += max(recur(cur + len - 1, cur, n),
                max(recur(cur + len, cur, n), recur(cur + len + 1, cur, n)));
  dp[cur][len] = temp;
  return temp;
}
long long int ans = 0;
void dfs(long long int src, long long int p, vector<long long int> adj[],
         vector<long long int>& a, long long int m, long long int check,
         long long int pre, long long int counter) {
  if (counter != 0 && adj[src].size() == 1) {
    if (a[src] == 1)
      check = max(check, pre + 1);
    else
      check = max(check, pre);
    if (check <= m) ans++;
    return;
  }
  for (int i = 0; i < adj[src].size(); i++) {
    if (adj[src][i] != p) {
      if (a[src] == 1) {
        check = max(check, pre + 1);
        if (check > m) return;
        dfs(adj[src][i], src, adj, a, m, check, pre + 1, counter + 1);
      } else {
        dfs(adj[src][i], src, adj, a, m, check, 0, counter + 1);
      }
    }
  }
}
void lcs() {
  vector<int> d;
  int ans, n;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    vector<int>::iterator it = upper_bound(d.begin(), d.end(), x);
    if (it == d.end())
      d.push_back(x);
    else
      *it = x;
  }
  printf("LIS = %d", d.size());
}
long long int find(long long int u, vector<long long int>& parent) {
  if (u == parent[u])
    return u;
  else
    return parent[u] = find(parent[u], parent);
}
void unio(long long int u, long long int v, vector<long long int>& parent,
          vector<long long int>& ran) {
  u = find(u, parent);
  v = find(v, parent);
  if (u == v) return;
  if (ran[u] >= ran[v]) {
    parent[v] = u;
    ran[u] += v;
  } else {
    parent[u] = v;
    ran[v] += u;
  }
}
long long int dfs(long long int src, long long int p,
                  vector<long long int> adj[], vector<long long int>& sz) {
  sz[src] = 1;
  for (int i = 0; i < adj[src].size(); i++) {
    long long int v = adj[src][i];
    if (v == p) continue;
    sz[src] += dfs(v, src, adj, sz);
  }
  return sz[src];
}
long long int dfs1(long long int src, long long int p,
                   vector<long long int> adj[], vector<long long int>& dp,
                   long long int m) {
  dp[src] = 1;
  for (int i = 0; i < adj[src].size(); i++) {
    long long int v = adj[src][i];
    if (v == p) continue;
    long long int temp = 1;
    temp = dfs1(v, src, adj, dp, m);
    dp[src] = ((dp[src] % m) * (temp % m));
  }
  return dp[src] + 1;
}
void dfs2(long long int src, long long int p, vector<long long int> adj[],
          vector<long long int>& dp, vector<long long int>& ans,
          long long int m) {
  ans[src] = dp[src];
  for (int i = 0; i < adj[src].size(); i++) {
    long long int v = adj[src][i];
    if (v == p) continue;
    dp[src] /= (dp[v] + 1);
    dp[v] = ((dp[v] % m) * (dp[src] + 1) % m) % m;
    dfs2(v, src, adj, dp, ans, m);
    dp[v] /= (dp[src] + 1);
    dp[src] = ((dp[src] % m) * (dp[v] + 1) % m);
  }
  return;
}
inline long long int add(long long int a, long long int b) {
  return ((a % mod) + (b % mod)) % mod;
}
inline long long int sub(long long int a, long long int b) {
  return ((a % mod) - (b % mod) + mod) % mod;
}
inline long long int mul(long long int a, long long int b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long int dfs1(vector<long long int> adj[], long long int src,
                   long long int p, long long int col,
                   vector<long long int>& dp) {
  dp[src] = 1;
  for (int i = 0; i < adj[src].size(); i++) {
    long long int v = adj[src][i];
    if (v == p) continue;
    long long int st = dfs1(adj, v, src, 1, dp);
    if (col == 1) {
      long long int temp = 0;
      temp = add(temp, dfs1(adj, v, src, 0, dp));
      temp = add(temp, st);
      dp[src] = mul(dp[src], temp);
    } else {
      dp[src] = mul(dp[src], st);
    }
  }
  return dp[src];
}
long long int recur(long long int idx, vector<long long int>& a,
                    long long int n, long long int k,
                    vector<vector<long long int> >& dp) {
  if (k == 0) return 1;
  if (k < 0) return 0;
  if (idx == n) return 0;
  if (dp[idx][k] != -1) return dp[idx][k];
  long long int temp = a[idx];
  long long int ans = 0;
  for (int i = 0; i <= min(temp, k); i++) {
    ans = add(ans, recur(idx + 1, a, n, k - i, dp));
  }
  dp[idx][k] = ans;
  return ans;
}
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long int> > dp(n, vector<long long int>(k + 1, -1));
  long long int ans = recur(0, a, n, k, dp);
  cout << ans;
  return 0;
}
