'use strict'

const mod = 1e9 +7

function solve(N, K, A) {
  if (K === 0) {
    return 1
  }
  if (N === 1) {
    return 0
  }
  var dp = new Array(N).fill(0).map(e => new Array(K+1).fill(0))
  for (var i = N-1; i > 0; i--) {
    for (var j = 0; j <= K; j++) {
      if (i === (N-1)) {
        if (A[i] >= j) {
          dp[i][j] = 1
        } else {
          break
        }
      } else {
        for (var k = 0; k <= A[i]; k++) {
          if ((j-k) >= 0) {
            dp[i][j] = (dp[i][j] + dp[i+1][j-k]) % mod
          }
        }
      }
    }
  }
  for (var i = 0; i <= A[0]; i++) {
    if ((K-i) >= 0) {
      dp[0][K] = (dp[0][K] + dp[1][K-i]) % mod
    }
  }
  return dp[0][K]
}

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'));