#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  const long long mod = 1e9 + 7;
  long long dp[2][100001];
  dp[0][0] = 1;
  dp[1][0] = 1;
  for (int i = 0; i < (N); i++) {
    int a;
    cin >> a;
    auto mae = dp[i & 1];
    auto tugi = dp[!(i & 1)];
    for (int j = 1; j <= (a); j++) {
      tugi[j] = (tugi[j - 1] + mae[j]) % mod;
    }
    auto are = tugi - a - 1;
    for (int j = a + 1; j <= K; j++) {
      tugi[j] = (tugi[j - 1] + mae[j] - are[j]) % mod;
    }
  }
  cout << ((dp[N & 1][K] + mod) % mod) << "\n";
  return 0;
}
