#include <bits/stdc++.h>
using namespace std;
ofstream fo("output.out");
using ll = long long;
const int mod = 1e9 + 7;
void add_self(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  vector<int> sum(k + 2, 0);
  for (int child = 0; child < n; ++child) {
    int up_to;
    cin >> up_to;
    for (int candies = k; candies >= 0; --candies) {
      int temp = dp[candies];
      int L = 1, R = min(up_to, k - candies);
      if (L <= R) {
        add_self(sum[candies + L], temp);
        add_self(sum[candies + R + 1], -temp);
      }
    }
    for (int i = 0; i <= k; ++i) {
      add_self(sum[i + 1], sum[i]);
      add_self(dp[i], sum[i]);
      sum[i] = 0;
    }
  }
  cout << dp[k];
}
