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 collections import deque
  from heapq import heappush, heappop
  import sys
  import math
  import bisect
  import random
  
  
  def LI():
      return list(map(int, sys.stdin.readline().split()))
  
  
  def I():
      return int(sys.stdin.readline())
  
  
  def LS():
      return list(map(list, sys.stdin.readline().split()))
  
  
  def S():
      return list(sys.stdin.readline())[:-1]
  
  
  def IR(n):
      l = [None for i in range(n)]
      for i in range(n):
          l[i] = I()
      return l
  
  
  def LIR(n):
      l = [None for i in range(n)]
      for i in range(n):
          l[i] = LI()
      return l
  
  
  def SR(n):
      l = [None for i in range(n)]
      for i in range(n):
          l[i] = S()
      return l
  
  
  def LSR(n):
      l = [None for i in range(n)]
      for i in range(n):
          l[i] = SR()
      return l
  
  
  sys.setrecursionlimit(1000000)
  mod = 1000000007
  
  
  # A
  def A():
      n, k = LI()
      a = LI()
      dp = [0 for i in range(k + 1)]
      f = [0 for i in range(k + 1)]
      for i in range(k + 1):
          if not f[i]:
              for j in a:
                  if i - j >= 0:
                      dp[i] = 1 - dp[i - j]
                      if dp[i] == 0:
                          break
              else:
                  dp[i] = 1
      print(["First", "Second"][dp[k]])
  
  
  # B
  def B():
      n = I()
      a = LI()
      ma = n * (n + 1) // 2
      su = sum(a)
      s = [1 for i in range(n + 1)]
      for i in range(1, n):
          s[i + 1] = s[i] + n - i + 1
      d = [None for i in range(ma + 1)]
      d[0] = 0
      k = 1
      for i in range(1, n + 1):
          for j in range(n + 1 - i):
              d[k + j] = i
          k += n + 1 - i
      k = n % 2
      dp = [su if (d[i] + k) % 2 else -su for i in range(ma + 1)]
      dp[0] = 0
      if k:
          for i in range(n):
              dp[i + 1] = a[n - 1 - i]
      else:
          for i in range(n):
              dp[i + 1] = -a[n - 1 - i]
      for i in range(1, ma):
          r = n - 1 - (i - s[d[i]])
          l = r + 1 - d[i]
          j = i + (n - d[i])
          j2 = j + 1
          if (d[i] + k) % 2:
              if r < n - 1:
                  if a[r + 1] + dp[i] > dp[j]:
                      dp[j] = a[r + 1] + dp[i]
              if l > 0:
                  if a[l - 1] + dp[i] > dp[j2]:
                      dp[j2] = a[l - 1] + dp[i]
          else:
              if r < n - 1:
                  if -a[r + 1] + dp[i] < dp[j]:
                      dp[j] = -a[r + 1] + dp[i]
              if l > 0:
                  if -a[l - 1] + dp[i] < dp[j2]:
                      dp[j2] = -a[l - 1] + dp[i]
      print(dp[ma])
      return
  
  
  # C
  def C():
      def comb(a, b):
          return fact[a] * inv[b] * inv[a - b] % mod
  
      n, k = LI()
      a = LI()
      """
      fact = [1]
      for i in range(n+k):
          fact.append(fact[-1]*(i+1)%mod)
      inv = [1]*(n+k+1)
      inv[n+k] = pow(fact[n+k],mod-2,mod)
      for i in range(n+k)[::-1]:
          inv[i] = inv[i+1]*(i+1)%mod
      f = [comb(i+n-1,n-1) for i in range(k+1)]
      for i in a:
          for j in range(k-i)[::-1]:
              f[j+i+1] -= f[j]
              f[j+i+1] %= mod
      print(f[k])
      """
      dp = [[0] * (k + 1) for i in range(n + 1)]
      for i in range(k + 1):
          dp[0][i] = 1
      for i in range(n):
          ni = i + 1
          ai = a[i]
          for j in range(k + 1):
              if j >= ai + 1:
                  dp[ni][j] = (dp[i][j] - dp[i][j - ai - 1]) % mod
              else:
                  dp[ni][j] = dp[i][j]
          if i < n - 1:
              for j in range(k):
                  dp[ni][j + 1] += dp[ni][j]
                  dp[ni][j + 1] %= mod
      print(dp[n][k] % mod)
      return
  
  
  # D
  def D():
      return
  
  
  # E
  def E():
      n = I()
      a = LIR(n)
      b = [1 << i for i in range(n + 1)]
      dp = [0 for i in range(b[n])]
      dp[0] = 1
      for i in range(n):
          for k in range(b[n])[::-1]:
              for j in range(n):
                  if a[i][j] and not b[j] & k:
                      dp[b[j] | k] += dp[k]
                      dp[b[j] | k] %= mod
      print(dp[-1])
  
  
  # F
  def F():
      return
  
  
  # G
  def G():
      return
  
  
  # H
  def H():
      return
  
  
  # Solve
  if __name__ == "__main__":
      C()
  
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."}]