#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long INF = 1e18;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int LIMIT = 1e6 + 1;
vector<long long> FacMod(LIMIT), InvMod(LIMIT), FacInvMod(LIMIT);
const int dpComTableLIMIT = 3e3 + 1;
vector<vector<long long>> Com(dpComTableLIMIT,
                              vector<long long>(dpComTableLIMIT, 0));
const int ComKTableLIMIT = 1e7;
vector<long long> ComK(ComKTableLIMIT);
void DPComInit() {
  for (int i = 0; i < dpComTableLIMIT; i++) {
    Com[i][0] = 1;
  }
  for (int i = 1; i < dpComTableLIMIT; i++) {
    for (int j = 1; j < dpComTableLIMIT; j++) {
      Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
    }
  }
}
void ComKInit(long long N) {
  for (int i = 0; i <= ComKTableLIMIT; i++) {
    if (0 < i && i <= N / 2) {
      ComK[i] = (ComK[i - 1] * (N - i + 1) / i) % MOD;
    } else if (i == 0) {
      ComK[i] = 1;
    } else if (N / 2 < i && i <= N) {
      ComK[i] = ComK[N - i];
    } else {
      ComK[i] = -1;
    }
  }
}
void ComInit() {
  FacMod[0] = FacMod[1] = 1;
  InvMod[0] = 0;
  InvMod[1] = 1;
  FacInvMod[0] = FacInvMod[1] = 1;
  for (int i = 2; i < LIMIT; i++) {
    FacMod[i] = FacMod[i - 1] * i % MOD;
    InvMod[i] = -InvMod[MOD % i] * (MOD / i) % MOD + MOD;
    FacInvMod[i] = FacInvMod[i - 1] * InvMod[i] % MOD;
  }
}
long long ComMod(int n, int k) {
  if (n >= 0 && k >= 0 && n >= k) {
    return FacMod[n] * (FacInvMod[k] * FacInvMod[n - k] % MOD) % MOD;
  } else {
    return 0;
  }
}
long long power(long long x, long long y) {
  if (y < 0) {
    return 0;
  } else if (y == 0) {
    return 1LL;
  } else if (y % 2 == 0) {
    return power(x, y / 2) * power(x, y / 2);
  } else {
    return power(x, y - 1) * x;
  }
}
long long mpower(long long x, long long y, long long m) {
  if (y < 0) {
    return 0;
  } else if (y == 0) {
    return 1LL;
  } else if (y % 2 == 0) {
    return mpower(x, y / 2, m) * mpower(x, y / 2, m) % m;
  } else {
    return mpower(x, y - 1, m) * x % m;
  }
}
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return (a / GCD(a, b)) * b; }
pair<map<long long, long long>, bool> PrimeFactorization(long long N) {
  pair<map<long long, long long>, bool> ret;
  ret.second = true;
  if (N != 2) {
    while (N % 2 == 0) {
      N /= 2;
      ret.first[2]++;
      ret.second = false;
    }
  }
  for (long long i = 3; i * i <= N; i += 2) {
    while (N % i == 0) {
      N /= i;
      ret.first[i]++;
      ret.second = false;
    }
  }
  if (N != 1) {
    ret.first[N]++;
  }
  return ret;
}
bool compare_by_second(pair<long long, long long> a,
                       pair<long long, long long> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
class UnionFind {
  vector<int> parent;
  vector<int> rank;
  vector<int> size;

 public:
  UnionFind(int N);
  int root(int x);
  void unite(int x, int y);
  bool isUnited(int x, int y);
  int getRank(int x);
  int getSize(int x);
};
UnionFind::UnionFind(int N) : parent(N), rank(N, 1), size(N, 1) {
  for (int i = 0; i < N; i++) {
    parent[i] = i;
  }
}
int UnionFind::root(int x) {
  if (parent[x] == x) return x;
  return root(parent[x]);
}
void UnionFind::unite(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  if (rx == ry) return;
  long long xs = size[root(x)];
  long long ys = size[root(y)];
  size[root(x)] += ys;
  size[root(y)] += xs;
  if (rank[x] >= rank[y]) {
    parent[ry] = rx;
    rank[y] += 1;
  } else {
    parent[rx] = ry;
    rank[x] += 1;
  }
}
bool UnionFind::isUnited(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  parent[x] = rx;
  parent[y] = ry;
  rank[x] = 2;
  rank[y] = 2;
  return rx == ry;
}
int UnionFind::getRank(int x) { return rank[x]; }
int UnionFind::getSize(int x) { return size[root(x)]; }
bool isOK(long long condition) { return true; }
long long binary_search() {
  long long ok = 1e18;
  long long ng = -1;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (isOK(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  long long Amax = 0;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    Amax = max(Amax, A[i]);
  }
  vector<vector<long long>> dp(N + 1, vector<long long>(K + 1, 0));
  dp[0][0] = 1;
  vector<vector<long long>> sum(N + 1, vector<long long>(K + 2, 0));
  sum[0][0] = 0;
  for (int j = 1; j <= K + 1; j++) {
    sum[0][j] = 1;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= K; j++) {
      long long tmp = sum[i - 1][j + 1] - sum[i - 1][max(j - A[i - 1], 0LL)];
      dp[i][j] = (dp[i][j] + tmp) % MOD;
    }
    for (int j = 1; j <= K + 1; j++) {
      sum[i][j] = (sum[i][j - 1] + dp[i][j - 1]) % MOD;
    }
  }
  cout << dp[N][K] << endl;
  return 0;
}
