use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp: Vec<Vec<usize>> = vec![vec![0; k + 1]; n + 1];
    dp[0][0] = 1;
    for i in 1..n + 1 {
        for j in 1..k + 1 {
            dp[i - 1][j] += dp[i - 1][j - 1];
            dp[i - 1][j] %= MOD;
        }
        for j in 0..k + 1 {
            if j > a[i - 1] {
                dp[i][j] += dp[i - 1][j] - dp[i - 1][j - a[i - 1] - 1];
            } else {
                dp[i][j] += dp[i - 1][j];
            }
            dp[i][j] %= MOD;
        }
    }
    println!("{}", dp[n][k]);
}
