'use strict'

const mod = 1e9 +7

function solve(N, K, A) {
  if (K === 0) {
    return 1
  }
  if (N === 1) {
    return 0
  }
  var prefixSum = []
  for (var i = 0; i <= K; i++) {
    if (A[N-1] >= i) {
      if (!prefixSum.length) {
        prefixSum.push(1)
      } else {
        prefixSum.push(prefixSum[prefixSum.length - 1] + 1)
      }
    } else {
      if (!prefixSum.length) {
        prefixSum.push(0)
      } else {
        prefixSum.push(prefixSum[prefixSum.length - 1])
      }
    }
  }
  var newPrefix = new Array(K+1).fill(0)
  for (var i = N - 2; i > 0; i--) {
    for (var j = 0; j <= K; j++) {
      if (j <= A[i]) {
        newPrefix[j] = j > 0 ? (prefixSum[j] + newPrefix[j-1]) % mod : prefixSum[j] % mod
      } else {
        newPrefix[j] = j > 0 ? (newPrefix[j-1] + prefixSum[j] - prefixSum[j - A[i] - 1]) % mod : (prefixSum[j] - prefixSum[j - A[i] - 1]) % mod
      }
    }
    prefixSum = newPrefix
  }
  var ans = 0
  if (K <= A[0]) {
    ans = prefixSum[K] % mod
  } else {
    ans = (prefixSum[K] - prefixSum[K - A[0] - 1]) % mod
  }
  return ans
}

function main(input) {
  var lines = input.split("\n")
  var NK = lines[0].split(' ').map(l => parseInt(l))
  var N = NK[0]
  var K = NK[1]
  var A = lines[1].split(' ').map(l => parseInt(l))
  var ans = solve(N, K, A)
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));