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: from sys import stdin, stdout, setrecursionlimit
  from collections import deque, defaultdict, Counter
  from heapq import heappush, heappop
  import math
  
  rl = lambda: stdin.readline()
  rll = lambda: stdin.readline().split()
  rli = lambda: map(int, stdin.readline().split())
  rlf = lambda: map(float, stdin.readline().split())
  
  INF, NINF = float("inf"), float("-inf")
  
  
  def pprint(M):
      for row in M:
          print(row)
      print("~~~")
  
  
  def main():
      MOD = 10**9 + 7
      n, k = rli()
      A = list(rli())
      dp = [[0 for __ in range(k + 1)] for _ in range(n)]
      psums = [[0 for __ in range(k + 1)] for _ in range(n)]
      for c in range(min(k + 1, A[0] + 1)):
          dp[0][c] = 1
      psums[0][0] = dp[0][0]
      for c in range(1, k + 1):
          psums[0][c] = dp[0][c] + psums[0][c - 1]
          psums[0][c] %= MOD
      for r in range(1, n):
          for c in range(k + 1):
              cutoff = c - A[r] - 1
              dp[r][c] = psums[r - 1][c] - (psums[r - 1][cutoff] if cutoff >= 0 else 0)
              dp[r][c] %= MOD
          psums[r][0] = dp[r][0]
          for c in range(1, k + 1):
              psums[r][c] = dp[r][c] + psums[r][c - 1]
              psums[r][c] %= MOD
      print(dp[n - 1][k] % MOD)
      stdout.close()
  
  
  if __name__ == "__main__":
      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."}]