use std::io::*;
const MOD: u64 = 1_000_000_007;
mod fenwick_tree {
    use std::ops::*;
    #[derive(Clone)]
    pub struct FenwickTree<T, F> {
        data: Vec<T>,
        identity: T,
        operation: F,
    }
    impl<T: Copy + Clone, F: Fn(T, T) -> T> FenwickTree<T, F> {
        pub fn new(size: usize, id: T, op: F) -> FenwickTree<T, F> {
            FenwickTree {
                data: vec![id; size + 1],
                identity: id,
                operation: op,
            }
        }
        pub fn query(&self, i: usize) -> T {
            let mut res = self.identity;
            let mut idx = i as isize - 1;
            while idx >= 0 {
                res = (self.operation)(res, self.data[idx as usize]);
                idx = (idx & (idx + 1)) - 1;
            }
            res
        }
        pub fn update(&mut self, i: usize, x: T) {
            let mut idx = i;
            while idx < self.data.len() {
                self.data[idx] = (self.operation)(self.data[idx], x);
                idx |= idx + 1;
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp = vec![fenwick_tree::FenwickTree::new(k + 1, 0, |a, b| a + b); n + 1];
    dp[0].update(0, 1);
    for i in 1..n + 1 {
        for j in (0..k + 1).rev() {
            let mut tmp = (dp[i - 1].query(j + 1) % MOD
                - dp[i - 1].query(j - std::cmp::min(j, a[i - 1])) % MOD
                + MOD)
                % MOD;
            tmp %= MOD;
            dp[i].update(j, tmp);
        }
    }
    println!(
        "{}",
        (dp[n].query(k + 1) % MOD - dp[n].query(k) % MOD + MOD) % MOD
    );
}
