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

fn min_insertions(s: String) -> i32 {
    let s = s.as_bytes();
    let n = s.len();
    println!("{}",n);
    let mut dp = vec![vec![10i32.pow(9)+7;n];n];
    for i in 0..n{
        dp[i][i] = 0;
        if i > 0{
            dp[i][i-1] = 0;
        }
    }
    // println!("{}",1);
    for len in 2..=n{
        for i in 0..(n-len+1){
            let j = i+len-1;
            if s[i] == s[j]{
                dp[i][j] = dp[i+1][j-1];
            }else{
                dp[i][j] = min(dp[i+1][j],dp[i][j+1])+1;
            }
        }
    }
    return dp[0][n-1];
}
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]);
}