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: def read_int():
      return int(input().strip())
  
  
  def read_ints():
      return list(map(int, input().strip().split(" ")))
  
  
  def solve():
      """
          OPT[N][K] = sum(OPT[N-1][K-i]) 0 <= i <= A[N]
          OPT[0][0] = 1
          N*K
          3 4
          1 2 3
  
      1 0 0 0 0
      1 1 0 0 0
      1 2 2 1 0
      1 3 5 6 5
  
      OPT[3][1] = OPT[2][1]+OPT[2][0]
      OPT[3][2] = OPT[2][2]+OPT[2][1]+OPT[2][0]
      OPT[3][3] = OPT[2][3]+OPT
      """
      N, K = read_ints()
      A = read_ints()
      modulo = 10**9 + 7
      OPT = [[0] * (K + 1) for _ in range(N + 1)]
      for i in range(N + 1):
          OPT[i][0] = 1
      for j in range(K + 1):
          OPT[0][j] = 1
      for i in range(1, N + 1):
          for j in range(1, K + 1):
              OPT[i][j] += OPT[i][j - 1] + OPT[i - 1][j]
              if j - A[i - 1] - 1 >= 0:
                  OPT[i][j] -= OPT[i - 1][j - A[i - 1] - 1]
              OPT[i][j] %= modulo
      return (OPT[-1][-1]) % modulo
  
  
  if __name__ == "__main__":
      print(solve())
  
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."}]