#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long power_without_mod(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
bool comparep(pair<long long, long long> i1, pair<long long, long long> i2) {
  return (i1.second < i2.second);
}
long long modInverse(long long a) { return power(a, 1000000007 - 2); }
vector<vector<long long>> graph;
vector<long long> num;
vector<bool> visited;
vector<long long> dist;
void bfs(int u) {
  queue<long long> q;
  q.push(u);
  visited[u] = 1;
  while (!q.empty()) {
    int u1 = q.front();
    q.pop();
    for (auto i = graph[u1].begin(); i != graph[u1].end(); i++) {
      num[*i]--;
      dist[*i] = max(dist[u1] + 1, dist[*i]);
      if (!visited[*i] && num[*i] == 0) {
        visited[*i] = 1;
        q.push(*i);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  for (long long z = 0; z < t; z++) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    for (__typeof(n) i = 0; i < n; ++i) {
      cin >> a[i];
    };
    long long dp[n][k + 1];
    for (long long i = 0; i < n; i++) {
      if (i == 0) {
        for (long long j = 0; j <= a[i]; j++) {
          dp[i][j] = 1;
          if (j) dp[i][j] += dp[i][j - 1];
          dp[i][j] %= 1000000007;
        }
        for (long long j = a[i] + 1; j <= k; j++) {
          dp[i][j] = dp[i][a[i]];
          dp[i][j] %= 1000000007;
        }
        continue;
      }
      for (long long j = 0; j <= k; j++) {
        dp[i][j] = dp[i - 1][j];
        if ((j - a[i] - 1) >= 0) dp[i][j] -= dp[i - 1][(j - a[i] - 1)];
        dp[i][j] %= 1000000007;
      }
      if (i != n - 1) {
        for (long long j = 1; j <= k; j++) {
          dp[i][j] += dp[i][j - 1];
          dp[i][j] %= 1000000007;
        }
      }
    }
    if (n != 1)
      cout << dp[n - 1][k];
    else {
      if (k <= a[0])
        cout << "1";
      else
        cout << "0";
    }
  }
}
