#include <bits/stdc++.h>
using namespace std;
template <typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
template <typename T>
T gcd(T a, T b) {
  if (b > 0) {
    return gcd(b, a % b);
  } else {
    return a;
  }
}
template <typename T>
T lcm(T a, T b) {
  T g = gcd(a, b);
  return a / g * b;
}
void clear(std::queue<pair<int, int> > &q) {
  std::queue<pair<int, int> > empty;
  std::swap(q, empty);
}
bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
template <typename T>
int GetDigit(T num) {
  int digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}
template <typename T>
std::vector<T> enum_div(T n) {
  std::vector<T> ret;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
class DisjointSet {
 public:
  vector<int> rank, p;
  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for (int i = 0; i < size; i++) {
      makeSet(i);
    }
  }
  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }
  bool same(int x, int y) { return findSet(x) == findSet(y); }
  void unite(int x, int y) { link(findSet(x), findSet(y)); }
  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }
  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};
int main() {
  int N, K;
  cin >> N >> K;
  long long a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long dp[N + 1][K + 1];
  long long sum[N + 1][K + 1];
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      dp[i][j] = 0;
      sum[i][j] = 0;
    }
  }
  dp[0][K] = 1;
  for (int j = 0; j < K + 1; j++) {
    sum[0][j] = 1;
  }
  for (int i = 0; i < N; i++) {
    for (int j = K; j >= 0; j--) {
      if (j + a[i] < K) {
        dp[i + 1][j] = sum[i][j] - sum[i][j + a[i] + 1];
      } else {
        dp[i + 1][j] = sum[i][j];
      }
      if (j == K) {
        sum[i + 1][j] = dp[i][j];
      } else {
        sum[i + 1][j] = sum[i + 1][j + 1] + dp[i + 1][j];
      }
    }
  }
  cout << dp[N][0] % 1000000007 << endl;
}
