#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    const U_INF: usize = 1 << 60;
    const I_INF: isize = 1 << 60;
    const MOD: i128 = 1000000007;

    let n: usize = read!();
    let k: usize = read!();
    let mut a = Vec::new();
    for _ in 0..n {
        let ai: usize = read!();
        a.push(ai);
    }

    let mut dp = vec![vec![0i128; k * 2 + 10]; n + 10];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..=k {
            let d = dp[i][j];
            let ai = a[i];
            dp[i + 1][j] += d;
            dp[i + 1][j + ai + 1] -= d;
        }

        for j in 0..=k {
            if j != 0 {
                dp[i + 1][j] += dp[i + 1][j - 1];
            }
            dp[i + 1][j] %= MOD;
        }
    }

    println!("{}", dp[n][k]);
}
