use std::cmp;
use proconio::input;

macro_rules! __memoize_internal {
  (@vec $FRetT:ty) => {
    Option<$FRetT>
  };
  (@vec $FRetT:ty, $memo_param_head:ident $(, $memo_param:ident)*) => {
    Vec<__memoize_internal!(@vec $FRetT $(, $memo_param)*)>
  };
  (@indices [$($t:tt)*]) => {
    [$($t)*]
  };
  (
    @indices [$($t:tt)*]
    $memo_param_head:ident
    $(, $memo_param:ident $(($memo_param_expr:expr))*)*
  ) => {
    __memoize_internal!(
      @indices [$($t)* $memo_param_head as usize,] $($memo_param $(($memo_param_expr))*),*
    )
  };
  (
    @indices [$($t:tt)*]
    $memo_param_head:ident($memo_param_expr_head:expr)
    $(, $memo_param:ident $(($memo_param_expr:expr))*)*
  ) => {
    __memoize_internal!(
      @indices [$($t)* $memo_param_expr_head(&$memo_param_head),]
      $($memo_param $(($memo_param_expr))*),*
    )
  };
  (@get $memo:expr, $indices:expr, $i:expr) => {
    $memo
  };
  (@get $memo:expr, $indices:expr, $i:expr, $memo_param_head:ident $(, $memo_param:ident)*) => {
    __memoize_internal!(
      @get $memo.and_then(|memo| memo.get($indices[$i])), $indices, $i + 1 $(, $memo_param)*
    )
  };
  (@resize $memo:expr, $indices:expr, $i:expr) => {};
  (@resize $memo:expr, $indices:expr, $i:expr, $memo_param_head:ident $(, $memo_param:ident)*) => {
    if $memo.len() < $indices[$i] + 1 {
      $memo.resize($indices[$i] + 1, <_>::default());
    }
    __memoize_internal!(
      @resize $memo[$indices[$i]], $indices, $i + 1 $(, $memo_param)*
    )
  };
  (@index $memo:expr, $indices:expr, $i:expr) => {
    $memo
  };
  (@index $memo:expr, $indices:expr, $i:expr, $memo_param_head:ident $(, $memo_param:ident)*) => {
    __memoize_internal!(
      @index $memo[$indices[$i]], $indices, $i + 1 $(, $memo_param)*
    )
  };
}

macro_rules! memoize {
  (
    #[memo_param($($memo_param:ident $(($memo_param_expr:expr))*),+)]
    $(#[$meta:meta])*
    fn $f:ident($memo:ident: _ $(, $f_param:ident: $FParamT:ty)*) -> $FRetT:ty $f_body:block
  ) => {
    $(#[$meta])*
    fn $f(
      $memo: &mut __memoize_internal!(@vec $FRetT $(, $memo_param)+)
      $(, $f_param: $FParamT)+
    ) -> $FRetT {
      let indices = __memoize_internal!(@indices [] $($memo_param $(($memo_param_expr))*),+);

      if let Some(&Some(ref ret)) =
        __memoize_internal!(@get Some(&$memo), indices, 0 $(, $memo_param)+)
      {
        return ret.clone();
      }

      let ret = $f_body;

      __memoize_internal!(@resize $memo, indices, 0 $(, $memo_param)+);
      __memoize_internal!(@index $memo, indices, 0 $(, $memo_param)+) = Some(ret.clone());

      ret
    }
  };
}

const MOD: i64 = 1000000007;

fn main() {
  input! {
    n : usize, k: i64,
    a: [i64; n]
  }
  
  memoize! {
    #[memo_param(anum, ame)]
    fn solve(memo: _, anum: usize, ame: i64, n : usize, k: i64, a: &Vec<i64>) -> i64 {
      match (anum, ame) {
        (_, i) if i == k => 1,
        (i, _) if i >= n => 0,
        _ => (ame..=cmp::min(k, ame + a[anum])).map(|i| solve(memo, anum + 1, i, n, k, a)).fold(0, |acc, x| (acc + x) % MOD)
      }
    }
  }
  println!("{}", solve(&mut vec![], 0, 0, n, k, &a));
}

