output_description: Print the number of ways for the children to share candies, modulo 10^9 + 7.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      a_1 a_2 \ldots a_N
attempt: #!/usr/bin/env python3
  
  # from collections import defaultdict
  # from heapq import heappush, heappop
  import sys
  
  sys.setrecursionlimit(10**6)
  input = sys.stdin.buffer.readline
  INF = 10**9 + 1  # sys.maxsize # float("inf")
  MOD = 10**9 + 7
  
  
  def debug(*x):
      print(*x, file=sys.stderr)
  
  
  def solve(N, K, XS):
      table = [0] * (K + 1)
      for i in range(XS[0] + 1):
          table[i] = 1
  
      for i in range(1, N):
          v = 0
          newtable = [0] * (K + 1)
          accum = [0] * (K + 1)
          acc = 0
          for j in range(K + 1):
              acc += table[j]
              accum[j] = acc
  
          # debug(": table", table)
          # debug(": accum", accum)
          for j in range(K + 1):
              # v = 0
              # for k in range(XS[i] + 1):
              #     if j - k < 0:
              #         break
              #     v += table[j - k]
              #     v %= MOD
              v = accum[j]
              k = j - XS[i] - 1
              if k >= 0:
                  v -= accum[k]
  
              newtable[j] = v % MOD
          table = newtable
  
      return table[K]
  
  
  def main():
      # parse input
      N, K = map(int, input().split())
      XS = list(map(int, input().split()))
  
      print(solve(N, K, XS))
  
  
  # tests
  T1 = """
  3 4
  1 2 3
  """
  
  
  def test_T1():
      """
      >>> as_input(T1)
      >>> main()
      5
      """
  
  
  T2 = """
  1 10
  9
  """
  
  
  def test_T2():
      """
      >>> as_input(T2)
      >>> main()
      0
      """
  
  
  T3 = """
  2 0
  0 0
  """
  
  
  def test_T3():
      """
      >>> as_input(T3)
      >>> main()
      1
      """
  
  
  T4 = """
  4 100000
  100000 100000 100000 100000
  """
  
  
  # def test_T4():
  #     """
  #     >>> as_input(T4)
  #     >>> main()
  #     """
  # add tests above
  
  
  def _test():
      import doctest
  
      doctest.testmod()
  
  
  def as_input(s):
      "use in test, use given string as input file"
      import io
  
      global read, input
      f = io.StringIO(s.strip())
  
      def input():
          return bytes(f.readline(), "ascii")
  
      def read():
          return bytes(f.read(), "ascii")
  
  
  USE_NUMBA = False
  if (USE_NUMBA and sys.argv[-1] == "ONLINE_JUDGE") or sys.argv[-1] == "-c":
      print("compiling")
      from numba.pycc import CC
  
      cc = CC("my_module")
      cc.export("solve", solve.__doc__.strip().split()[0])(solve)
      cc.compile()
      exit()
  else:
      input = sys.stdin.buffer.readline
      read = sys.stdin.buffer.read
  
      if (USE_NUMBA and sys.argv[-1] != "-p") or sys.argv[-1] == "--numba":
          # -p: pure python mode
          # if not -p, import compiled module
          from my_module import solve  # pylint: disable=all
      elif sys.argv[-1] == "-t":
          print("testing")
          _test()
          sys.exit()
      elif sys.argv[-1] != "-p" and len(sys.argv) == 2:
          # input given as file
          input_as_file = open(sys.argv[1])
          input = input_as_file.buffer.readline
          read = input_as_file.buffer.read
  
      main()
  
problem_description: Statement
  
  There are N children, numbered 1, 2, \ldots, N.
  
  They have decided to share K candies among themselves. Here, for each i (1
  \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive).
  Also, no candies should be left over.
  
  Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two
  ways are said to be different when there exists a child who receives a
  different number of candies.
samples: [{"input": "3 4\n    1 2 3", "output": "5\n    \n\nThere are five ways for the children to share candies, as follows:\n\n  * (0, 1, 3)\n  * (0, 2, 2)\n  * (1, 0, 3)\n  * (1, 1, 2)\n  * (1, 2, 1)\n\nHere, in each sequence, the i-th element represents the number of candies that\nChild i receives.\n\n* * *"}, {"input": "1 10\n    9", "output": "0\n    \n\nThere may be no ways for the children to share candies.\n\n* * *"}, {"input": "2 0\n    0 0", "output": "1\n    \n\nThere is one way for the children to share candies, as follows:\n\n  * (0, 0)\n\n* * *"}, {"input": "4 100000\n    100000 100000 100000 100000", "output": "665683269\n    \n\nBe sure to print the answer modulo 10^9 + 7."}]