use std::cmp::*;
use std::io;

fn main(){
    let mut t_cases = 1;
    for i in 0..t_cases{
        solve();
    }
}
fn solve(){
    let MOD = 10i32.pow(9)+7;
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap());
    let n = iter.next().unwrap();
    let k = iter.next().unwrap();
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect::<Vec<_>>();
    let mut dp = vec![0i32;k+1];
    dp[0] = 1;
    for item in a{
        let mut tdp = dp.clone();
        let mut s = dp[0];
        for i in 1..(k+1){
            s+=dp[i];
            if i > (item){
                s-=dp[i-item-1];
            }
            s = (s)%MOD;
            tdp[i] = s;
        }
        dp = tdp;
        // println!("{:?}",dp);
    }
    println!("{}",dp[k]);
}