import sys

readline = sys.stdin.readline

N, K = map(int, readline().split())
A = list(map(int, readline().split()))

P = 10 ** 9 + 7

summ = 0
ind = -1
for i,a in enumerate(A):
    summ += a
    if summ > K:
        ind = i
        break

if ind == -1:
    print(0)
    exit()

right = ind

count = len(A) - right
    
for left in range(1, len(A) + 1):
    summ -= A[left - 1]
    while summ < K:
        right += 1
        if right >= len(A):
            break
        summ += A[right]
    if right >= len(A):
        break
    count += (len(A) - right) % P

print(count % P)