use std::io::*;
const MOD: u64 = 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<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

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