def main():
    MOD = 10**9 + 7
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    dp = [[0]*(K+1) for i in range(N+1)]
    dp[0][0] = 1
    S = [0] * (K+2)
    for i in range(1, N+1):
        S[0] = 0
        for j in range(1, K+2):
            S[j] = (S[j-1] + dp[i-1][j-1]) % MOD
        # print(S)
        for j in range(K+1):
            """
            for k in range(A[i-1]+1):
                # i番目の子供がk個受け取る
                if j - k >= 0:
                    dp[i][j] = (dp[i][j] + dp[i-1][j-k]) % MOD
            """
            dp[i][j] = (S[j+1] - S[max(0, j-A[i-1])] + MOD) % MOD
    print(dp[N][K])
    # for i in range(N+1):
    #     print(*dp[i])


if __name__ == '__main__':
    main()
