#include <bits/stdc++.h>
using namespace std;
void io_handler() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
template <typename T>
void print_matrix(vector<vector<T>> mat) {
  for (auto row : mat) {
    for (auto e : row) {
      cout << e << " ";
    }
    cout << endl;
  }
}
template <typename T>
void print_vector(vector<T> v) {
  for (auto e : v) {
    cout << e << " ";
  }
  cout << endl;
}
template <typename T>
map<T, T> get_count(vector<T> v) {
  map<T, T> count;
  for (auto e : v) {
    if (count.find(e) != count.end()) {
      count[e]++;
    } else {
      count[e] = 1;
    }
  }
  return count;
}
void add_self(long long &a, long long b) {
  a = a + b;
  if (a >= 1000000007) {
    a -= 1000000007;
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0LL));
  dp[0][0] = 1LL;
  vector<long long> arr(n);
  for (long long i = 0LL; i < n; i++) {
    cin >> arr[i];
  }
  for (long long i = 1LL; i <= n; i++) {
    vector<long long> pre(dp[i - 1].begin(), dp[i - 1].end());
    for (long long j = 1LL; j <= k; j++) {
      add_self(pre[j], pre[j - 1]);
    }
    for (long long j = 0LL; j <= k; j++) {
      add_self(dp[i][j], pre[j] - (j - min(arr[i - 1], j) - 1 >= 0
                                       ? pre[j - min(arr[i - 1], j) - 1]
                                       : 0LL));
    }
  }
  cout << dp[n][k] << endl;
}
int main() {
  io_handler();
  int t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
