use std::cmp::{max, min};
use std::error::Error;
use std::io;

const m: i64 = 1_000_000_007;

fn main() {
    if let Err(e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer)?;
    let first_line: Vec<usize> = buffer.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect();
    let n = first_line[0];
    let k = first_line[1];

    buffer.clear();
    io::stdin().read_line(&mut buffer)?;
    let candies: Vec<i32> = buffer.split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();

    let mut dp = vec![vec![0; k + 1]; n + 1];
    println!("{}", calculate(&mut dp, &candies, n, k));
    Ok(())
}

fn calculate(dp: &mut Vec<Vec<i64>>, candies: &Vec<i32>, n: usize, k: usize) -> i32 {
    for i in 0..=n {
        dp[i][0] = 1;
    }

    for i in 1..=n {
        for j in 1..=k {
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % m;
            if j - 1 >= candies[i - 1] as usize {
                dp[i][j] = (dp[i][j] + m - dp[i - 1][j - candies[i - 1] as usize - 1]) % m;
            }
        }
    }
    dp[n][k] as i32
}
