fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<usize>();
    let big_int = 1000_000_000 + 7;

    let mut dp = vec![vec![0u64; k + 1]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        let mut temp = 0u64;
        for j in 0..k + 1 {
            temp += dp[i][j];
            temp %= big_int;
            dp[i + 1][j] = temp;
            if j >= a[i] {
                temp = big_int - dp[i][j - a[i]];
                temp %= big_int;
            }
        }
    }
    println!("{:?}", dp[n][k] % big_int);
}
