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: u64 = 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();
    // dp_table
    let mut dp: Vec<Vec<u64>> = vec![vec![0; k+1]; n+1];

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

    for i in 0..n {
      // i列目を累積和に更新
      for j in 0..k {
        dp[i][j+1] += dp[i][j];
        dp[i][j+1] %= MOD;
      }
      //
      for j in 0..k+1 {
        // dp[i+1][j+1] = SUM(dp[i][l]) (for l = j - a_i ~ j)
        let l = max(0, j as i64 - a[i] as i64);

        if l == 0 {
          dp[i+1][j] = dp[i][j];
        } else  {
          dp[i+1][j] = dp[i][j] - dp[i][l as usize - 1];
        }

        dp[i+1][j] %= MOD;
      }
    }

    println!("{}", dp[n][k]);
}
