def main():
  M=10**9+7
  n,k,*a=map(int,open(0).read().split())
  b=[1]+[0]*k
  for i in a:
    t,d=0,[]
    for w,v in zip([0]*-~i+b,b):
      t+=v-w
      t%=M
      d+=t,
    b=d
  print(t)
main()