macro_rules! debug {
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    const MOD: u32 = 1_000_000_007;
    let N = stdin.read();
    let K: usize = stdin.read();
    let mut a = vec![0; N];
    for i in 0..N {
        a[i] = stdin.read();
    }

    let mut dp = vec![vec![0; K + 1]; N + 1];
    let mut dp_sum = vec![vec![0; K + 2]; N + 1];
    for i in 0..N + 1 {
        dp[i][0] = 1;
        dp_sum[i][0] = 0;
        dp_sum[i][0 + 1] = dp_sum[i][0] + dp[i][0];
    }
    for j in 1..K + 1 {
        dp[0][j] = 0;
        dp_sum[0][j + 1] = dp_sum[0][j] + dp[0][j];
    }
    
    for i in 1..N + 1 {
        for j in 1..K + 1 {
            /*
            for k in 0..std::cmp::min(j, a[i - 1]) + 1 {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - k]) % MOD;
            }
            */

            let l = if j >= a[i - 1] {
                j - a[i - 1]
            } else {
                0
            };
            /*
            for k in l..j + 1 {
                dp[i][j] = (dp[i][j] + dp[i - 1][k]) % MOD;
            }
            */

            dp[i][j] = (dp_sum[i - 1][j + 1] + (MOD - dp_sum[i - 1][l])) % MOD;
            dp_sum[i][j + 1] = (dp_sum[i][j] + dp[i][j]) % MOD;
            //println!("dp[{}][{}] = {}", i, j, dp[i][j]);
            //println!("dp_sum[{}][{}] = {}", i, j + 1, dp_sum[i][j + 1]);
        }
    }
    println!("{}", dp[N][K]);
}

mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}



Measured memory_bytes: 106748