#include <bits/stdc++.h>
using namespace std;
using long long int = long long int;
using pii = pair<int, int>;
using pll = pair<long long int, long long int>;
using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<pii>;
using vll = vector<pll>;
long long int mod = 1000000007;
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  static vector<vl> dp(N + 1, vl(K * 2 + 3, 0));
  dp[0][0] = 1;
  int a;
  for (long long int i = 0; i < N; i++) {
    scanf("%d", &a);
    for (long long int j = 0; j < K + 1; j++) {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j + a + 1] -= dp[i][j];
    }
    for (long long int j = 1; j < K + 1; j++) {
      dp[i + 1][j] += dp[i + 1][j - 1];
      dp[i + 1][j] %= mod;
    }
  }
  printf("%lld\n", dp[N][K]);
  return 0;
}
