use proconio::input;

const MOD: i64 = 1000000007;

fn main() {
  input! {
    n : usize, k: usize,
    a: [usize; n]
  }
  
  if (n == 1) {
    println!("{}", if k > a[0] { 0 } else { 1 });
    return;
  }
  
  let mut dp = vec![0; k + 1];
  dp[0] = 1;
  for i in 1..=a[n-1] {
    dp[i] = (dp[i - 1] + 1) % MOD;
  }
  for i in (a[n-1]+1)..=k {
    dp[i] = dp[i - 1];
  }

  for i in (1..(n-1)).rev() {
    let mut dp_next = vec![0; k + 1];
    dp_next[0] = 1;
    for j in 1..=a[i] {
      dp_next[j] = (dp_next[j-1] + dp[j]) % MOD;
    }
    for j in (a[i]+1)..=k {
      dp_next[j] = (dp_next[j - 1] + (dp[j] + MOD - dp[j - a[i] - 1]) % MOD) % MOD;
    }
    dp = dp_next;
  }
  if k > a[0] { dp[k] = (dp[k] + MOD - dp[k - a[0] - 1]) % MOD }
  println!("{}", dp[k]);
}

