#include <bits/stdc++.h>
using namespace std;
unsigned long long int expo_fast(long long int a, long long int b) {
  a = a;
  long long int result = 1;
  while (b) {
    if (b & 1) result = (result * a);
    b >>= 1;
    a = (a * a);
  }
  return (result);
}
void take_in(vector<long long int> *arr) {
  for (int i = 0; i < arr->size(); i++) cin >> (*(arr))[i];
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
unsigned long long int power(long long int x, unsigned long long int y,
                             long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> arr(n + 1);
  for (int i = 1; i <= n; i++) cin >> arr[i];
  vector<vector<long long int>> dp(k + 1, vector<long long int>(n + 1, 0));
  for (int i = 0; i <= k; i++) {
    dp[i][1] = (i <= arr[1]) ? 1 : 0;
  }
  for (int j = 2; j <= n; j++) {
    for (int i = 0; i <= k; i++) {
      if (i == 0)
        dp[i][j] = dp[i][j - 1] % (1000000007);
      else {
        if (i <= arr[j])
          dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (1000000007);
        else
          dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - arr[j] - 1][j - 1]) %
                     (1000000007);
      }
    }
  }
  cout << dp[k][n];
}
