#include <bits/stdc++.h>
using namespace std;
struct Grid {
  int x, y, t;
};
struct Edge {
  int to, cost;
};
struct Graph {
  vector<vector<Edge>> E;
  int V;
  const long long Inf = 1e18;
  const int MAX_V = 1010;
  vector<long long> d;
  Graph(int n) : E(n) {
    d.resize(MAX_V);
    E.resize(n);
    V = n;
  }
  void init() {
    for (int i = 0; i < MAX_V; i++) d[i] = Inf;
  }
  void add_edge(int from, int to, int cost) {
    E[from - 1].push_back({to - 1, cost});
  }
};
int main() {
  int n, k;
  cin >> n >> k;
  long long dp[2][k + 10];
  long long sum[2][k + 10];
  for (int i = 0; i < k + 10; i++)
    sum[1][i] = sum[0][i] = dp[0][i] = dp[1][i] = 0;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    long long hoge;
    cin >> hoge;
    sum[(i + 1) % 2][0] = dp[(i + 1) % 2][0];
    for (long long j = 1; j <= k; j++) {
      sum[(i + 1) % 2][j] = sum[(i + 1) % 2][j - 1] + dp[(i + 1) % 2][j];
      sum[(i + 1) % 2][j] %= 1000000007;
    }
    sum[(i + 1) % 2][k + 1] = sum[(i + 1) % 2][k];
    for (long long j = 0; j <= k; j++) {
      if (j == min(j, hoge))
        dp[i % 2][j] = sum[(i + 1) % 2][j];
      else
        dp[i % 2][j] =
            (sum[(i + 1) % 2][j] - sum[(i + 1) % 2][j - min(hoge, j) - 1]) %
            1000000007;
    }
  }
  cout << dp[n % 2][k] % 1000000007 << endl;
  return 0;
}
