use std::vec::Vec;
use std::cmp::*;

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> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

const MOD: usize = 1_000_000_000 + 7;

fn main() {
    let (n, k) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };

    let a: Vec<usize> = read_vec();

    let mut dp = vec![vec![0; k+1]; n+1];

    // init
    dp[0][0] = 1;

    for i in 0..n {
      // 累積和
      let sum = cum_sum(&dp[i]);

      for j in 0..k+1 {
        dp[i+1][j] = sum[j+1] - sum[j - min(j, a[i])];
        dp[i+1][j] %= MOD;
      }
    }
    
    println!("{}", dp[n][k]);
}

fn cum_sum(v: &Vec<usize>) -> Vec<usize> {
    let n = v.len();
    let mut sum = vec![0; n + 1];

    for i in 0..n {
        sum[i + 1] = sum[i] + v[i];
        sum[i + 1] %= MOD;
    }

    sum
}