You are given a sequence of positive integers of length N, A=a_1,a_2,…,a_{N}, and an integer K.
How many contiguous subsequences of A satisfy the following condition?
 - (Condition) The sum of the elements in the contiguous subsequence is at least K.
We consider two contiguous subsequences different if they derive from different positions in A, even if they are the same in content.
Note that the answer may not fit into a 32-bit integer type.

-----Constraints-----
 - 1 \leq a_i \leq 10^5
 - 1 \leq N \leq 10^5
 - 1 \leq K \leq 10^{10}

-----Input-----
Input is given from Standard Input in the following format:
N K
a_1 a_2 ... a_N

-----Output-----
Print the number of contiguous subsequences of A that satisfy the condition.

-----Sample Input-----
4 10
6 1 2 7

-----Sample Output-----
2

The following two contiguous subsequences satisfy the condition:
 - A[1..4]=a_1,a_2,a_3,a_4, with the sum of 16
 - A[2..4]=a_2,a_3,a_4, with the sum of 10

Source: atcoder | Difficulty: MEDIUM_HARD


Solutions:
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 0
s = A[0]
ans = 0
while True:
	if s >= K:
		ans += N - r
		s -= A[l]
		l += 1
	elif r < N - 1:
		r += 1
		s += A[r]
	else:
		break
print(ans)


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
	if i == 0:
		n = 0
		k = 0
	else:
		n -= a[i - 1]
		if n >= K:
			ans += N - k
			continue
		else:
			k += 1
	for j in range(k, N):
		n += a[j]
		if n >= K:
			k = j
			ans += N - j
			break
	else:
		print(ans)
		break
else:
	print(ans)


(N, K) = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
ans = N * (N - 1) // 2
k = 0
s = 0
for i in range(N):
	while s < K and k < N:
		s += A[k]
		k += 1
	if s >= K:
		k -= 1
		s -= A[k]
	ans -= k - i - 1
	s -= A[i]
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
j = 0
ans = 0
for i in range(n):
	s += a[i]
	while s >= k:
		ans += n - i
		s -= a[j]
		j += 1
print(ans)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
L = [0] * (N + 1)
for i in range(N):
	L[i + 1] = L[i] + A[i]
(r, cnt) = (0, 0)
for l in range(N):
	while r < N and L[r + 1] - L[l] < K:
		r += 1
	cnt += N - r
print(cnt)


import bisect
(N, K) = map(int, input().split())
A = [int(x) for x in input().split()]
left_sum = [0] * N
now = 0
for h in range(N):
	now += A[h]
	left_sum[h] = now
ans = 0
for i in range(N):
	target = K + left_sum[i] - A[i]
	ans += N - bisect.bisect_left(left_sum, target)
print(ans)


import math
import queue
import bisect
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
ipt = stdin.readline
setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
dir = [(-1, 0), (1, 0), (0, -1), (0, 1)]
alp = 'abcdefghijklmnopqrstuvwxyz'

def main():
	(n, k) = list(map(int, ipt().split()))
	a = [int(i) for i in ipt().split()]
	ans = 0
	sm = 0
	l = 0
	for i in range(n):
		sm += a[i]
		while sm >= k:
			sm -= a[l]
			l += 1
		ans += l
	print(ans)
	return None

def __starting_point():
	main()
__starting_point()


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
s_a = 0
ans = 0
idx = 0
for i in range(N):
	while s_a < K:
		if idx >= N:
			break
		s_a += a[idx]
		idx += 1
	if s_a >= K:
		ans += N - idx + 1
		s_a -= a[i]
	else:
		break
print(ans)


import math
from math import gcd, pi, sqrt
INF = float('inf')
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
from collections import Counter, deque

def i_input():
	return int(input())

def i_map():
	return list(map(int, input().split()))

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def main():
	(n, k) = i_map()
	a = i_list()
	X = [0] + list(itertools.accumulate(a))
	ans = 0
	from bisect import bisect_left
	for x in X:
		i = bisect_left(X, k + x)
		if i == n + 1:
			if X[-1] - x >= k:
				ans += 1
		else:
			ans += n - i + 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
left = 0
ans = 0
sum = 0
for right in range(n):
	sum += A[right]
	while sum >= k:
		sum -= A[left]
		left += 1
	ans += left
print(ans)


(n, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
R = [A[0]] * n
for i in range(n - 1):
	R[i + 1] = R[i] + A[i + 1]

def get(x):
	if x == 0:
		return 0
	return R[x - 1]
left = 0
right = 1
import bisect as bi
ans = 0
while 1:
	q = bi.bisect_left(R, get(left) + k)
	if q == n:
		print(ans)
		return
	ans += n - q
	left += 1


(N, K) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()] + [0]
cnt = 0
left = 0
right = 0
t = A[right]
while right < N:
	if t >= K:
		cnt += N - right
	if t >= K and left < right:
		t -= A[left]
		left += 1
	elif t >= K and left == right:
		left += 1
		right += 1
		t = A[right]
	else:
		right += 1
		t += A[right]
print(cnt)


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
L = 0
R = 0
rangeSum = a[0]
ans = 0
for i in range(N):
	L = i
	while rangeSum < K:
		R += 1
		if R >= len(a):
			break
		rangeSum += a[R]
	ans += max(N - R, 0)
	rangeSum -= a[L]
print(ans)


import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def main():
	(N, K) = NMI()
	A = NLI()
	left = 0
	right = 0
	shakutori = 0
	ans = 0
	for left in range(N):
		while shakutori < K and right < N:
			shakutori += A[right]
			right += 1
		if shakutori >= K:
			ans += N - right + 1
			shakutori -= A[left]
		else:
			break
	print(ans)

def __starting_point():
	main()
__starting_point()


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return list(map(int, input().split()))

def X():
	return list(input())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
inf = float('inf')
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
from itertools import accumulate
from bisect import bisect_left
a = [0] + list(accumulate(a))
ans = 0
for i in range(n + 1):
	j = bisect_left(a, k + a[i])
	ans = ans + n - j + 1
print(ans)


(N, K) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(1, N + 1):
	b[i] = b[i - 1] + a[i - 1]
ans = 0
j = 0
for i in range(1, N + 1):
	if b[i] - b[j] < K:
		continue
	ans += N + 1 - i
	while i > j:
		j += 1
		if b[i] - b[j] >= K:
			ans += N + 1 - i
		else:
			break
print(ans)


import bisect
(N, K) = list(map(int, input().split()))
a = list(map(int, input().split()))
S = [0] * N
S[0] = a[0]
for k in range(1, N):
	S[k] = S[k - 1] + a[k]
S = [0] + S
ans = 0
for k in range(N + 1):
	if S[k] >= K:
		ans += bisect.bisect_right(S, S[k] - K)
print(ans)


(N, K) = list(map(int, input().split()))
A = [0] + [int(x) for x in input().split()] + [0]
ans = 0
j = 0
tmp = 0
for i in range(1, N + 1):
	tmp -= A[i - 1]
	while tmp >= K and i < j:
		tmp -= A[j]
		j -= 1
	while tmp < K and j <= N:
		j += 1
		tmp += A[j]
	ans += N + 1 - j
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
cur = 0
r = -1
for l in range(n):
	stop = True
	if cur < k:
		while r < n - 1:
			r += 1
			cur += a[r]
			if cur >= k:
				cnt += n - r
				stop = False
				break
	elif cur > k:
		stop = False
		if r == l:
			cnt += n - r
		else:
			while r > l:
				cur -= a[r]
				r -= 1
				if cur <= k:
					r += 1
					cur += a[r]
					cnt += n - r
					break
	else:
		cnt += n - r
		stop = False
	cur -= a[l]
	if stop:
		break
print(cnt)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
a = [0]
for i in range(n):
	a.append(a[i] + A[i])

def is_ok(tmp, arg):
	return a[arg] - a[tmp] >= k
cnt = 0
for i in range(n):
	(top, bot) = (n + 1, i)
	while top - bot > 1:
		mid = (top + bot) // 2
		if is_ok(i, mid):
			top = mid
		else:
			bot = mid
	cnt += n - top + 1
print(cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(ans, s) = (0, 0)
r = 0
for l in range(n):
	while r < n and s < k:
		s += a[r]
		r += 1
	if s >= k:
		ans += n - r + 1
	s -= a[l]
print(ans)


from bisect import bisect_left, bisect_right
(n, k) = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
cuma = [0]
for i in range(1, n + 1):
	cuma.append(cuma[i - 1] + a[i])
if cuma[-1] < k:
	print(0)
	return
r = bisect_left(cuma, k)
ans = 0
for i in range(r, len(cuma)):
	l = bisect_right(cuma, cuma[i] - k)
	ans += l
print(ans)


from collections import deque
(N, K) = [int(i) for i in input().split()]
AS = [int(i) for i in input().split()]
l = deque()
s = 0
cnt = 0
s = 0
for i in range(N):
	a = AS[i]
	s += a
	l.append(a)
	if s >= K:
		cnt += N - i
		while s - l[0] >= K:
			s -= l[0]
			cnt += N - i
			l.popleft()
		s -= l[0]
		l.popleft()
print(cnt)


from itertools import accumulate
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
A_ = [0] + list(accumulate(A))
N_ = N + 1
x = 0
ans = 0
for i in range(N_):
	S = A_[i] - A_[x]
	if S >= K:
		while S >= K and x != i:
			ans += N_ - i
			x += 1
			S = A_[i] - A_[x]
print(ans)


import bisect
(N, K) = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
cusum = [0]
for i in range(N):
	cusum.append(cusum[i] + A[i])
for i in cusum:
	if i < K:
		continue
	ans += bisect.bisect(cusum, i - K)
print(ans)


import numpy as np
(N, K) = map(int, input().split())
INF = 10 ** 18
A = [0] + [int(x) for x in input().split()] + [INF]
A = np.array(A)
Acum = A.cumsum()
idx = np.searchsorted(Acum, Acum + K)
answer = (N + 1 - idx[:N]).sum()
print(answer)


from bisect import *
from numpy import *
(N, K, *A) = map(int, open(0).read().split())
B = [0] + list(cumsum(A))
print(sum((N + 1 - bisect_left(B, K + B[n]) for n in range(N + 1))))


INT = lambda : int(input())
INTM = lambda : map(int, input().split())
STRM = lambda : map(str, input().split())
STR = lambda : str(input())
LIST = lambda : list(map(int, input().split()))
LISTS = lambda : list(map(str, input().split()))

def do():
	(n, k) = INTM()
	A = LIST()
	suma = [0] * (n + 1)
	for i in range(n):
		suma[i + 1] = suma[i] + A[i]
	ans = 0
	for i in range(0, n + 1):
		low = i - 1
		high = n + 1
		check = suma[i] + k
		for j in range(20):
			mid = (low + high) // 2
			if suma[mid] < check:
				low = mid
			else:
				high = mid
		ans += n - low
	print(ans)

def __starting_point():
	do()
__starting_point()


(n, k, *a) = list(map(int, open(0).read().split()))
l = r = 0
s = 0
unko = 0
while l < n:
	while r < n and s < k:
		s += a[r]
		r += 1
	if s < k:
		break
	unko += n - r + 1
	s -= a[l]
	if l == r:
		r += 1
	l += 1
print(unko)


import sys

def solve(N: int, K: int, a: 'List[int]'):
	(su, left, ans) = (0, 0, 0)
	for right in range(N):
		su += a[right]
		while su - a[left] >= K:
			su -= a[left]
			left += 1
		ans += left + (su >= K)
		right += 1
	return ans

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	K = int(next(tokens))
	a = [int(next(tokens)) for _ in range(N)]
	print(solve(N, K, a))

def __starting_point():
	main()
__starting_point()


(N, K) = list(map(int, input().split()))
A = [int(x) for x in input().split()]
left = 0
right = 0
count = 0
total = 0
while left < N and right < N:
	total += A[right]
	while total >= K:
		count += N - right
		total -= A[left]
		left += 1
	right += 1
print(count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = [0] * n
s[0] = a[0]
for i in range(1, n):
	s[i] = s[i - 1] + a[i]
ans = 0
for i in range(n):
	tmp = s[i] - a[i]
	if s[n - 1] - tmp < k:
		continue
	if a[i] >= k:
		ans += n - i
		continue
	left = i - 1
	right = n
	while right - left > 1:
		mid = (left + right) // 2
		if s[mid] - tmp >= k:
			right = mid
		else:
			left = mid
	ans += n - right
print(ans)


import bisect
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
C = [0] * N
C[0] = A[0]
for i in range(1, N):
	C[i] = C[i - 1] + A[i]
ans = 0
for i in range(N):
	x = 0 if i == 0 else C[i - 1]
	ans += N - bisect.bisect_left(C, K + x)
print(ans)


(N, K) = list(map(int, input().split()))
A_list = list(map(int, input().split()))
A_ruisekiwa = [0] * (N + 1)
for i in range(1, N + 1):
	A_ruisekiwa[i] = A_ruisekiwa[i - 1] + A_list[i - 1]
import bisect
ans = 0
for i in range(N):
	a = K + A_ruisekiwa[i]
	t_i = bisect.bisect_left(A_ruisekiwa, a)
	if t_i <= N:
		ans += N - t_i + 1
print(ans)


import numpy as np
(n, k) = map(int, input().split())
a = [0] + list(map(int, input().split()))
a = list(np.cumsum(a))
cnt = 0
x = 1
for i in range(n):
	for j in range(x, n + 1):
		if a[j] - a[i] >= k:
			cnt += n + 1 - j
			x = j
			break
print(cnt)


import numpy as np
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
cum_A = np.cumsum(A)
cum_A = np.insert(cum_A, 0, 0)
cnt = 0
j = 1
for i in range(1, N + 1):
	while j <= N:
		if cum_A[j] - cum_A[i - 1] >= K:
			cnt += N - j + 1
			break
		j += 1
print(cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
from itertools import accumulate
ac = [0] + list(accumulate(a))
from bisect import bisect_left
count = 0
for i in range(1, n + 1):
	count += n - bisect_left(ac, k + ac[i - 1]) + 1
print(count)


from itertools import accumulate
from bisect import bisect_left
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
acc = [0] + list(accumulate(A, lambda x, y: x + y))
ans = 0
for i in range(N + 1):
	j = bisect_left(acc, K + acc[i], lo=i)
	ans += N + 1 - j
print(ans)


(n, k) = list(map(int, input().split()))
a_list = list(map(int, input().split()))
s = 0
t = 1
temp_sum = a_list[0]
ans = 0
while t <= n:
	if temp_sum >= k:
		temp_sum -= a_list[s]
		ans += n - t + 1
		s += 1
	else:
		if t >= n:
			break
		temp_sum += a_list[t]
		t += 1
print(ans)


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
count = 0
r = 0
l = 0
acc = 0
while r < n:
	while r < n:
		acc += ai[r]
		r += 1
		if acc >= k:
			break
	while l < r:
		if acc >= k:
			count += n - r + 1
			acc -= ai[l]
			l += 1
		else:
			break
print(count)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
cums = [0]
for a in A:
	cums.append(cums[-1] + a)
ans = 0
from bisect import bisect_left
for i in range(N):
	j = bisect_left(cums, cums[i] + K)
	ans += N + 1 - j
print(ans)


(N, K) = list(map(int, input().split()))
a = list(map(int, input().split()))
now = 0
ans = 0
position = 0
break_flag = 0
for i in range(N):
	while now < K:
		if position >= N:
			break_flag = 1
			break
		now += a[position]
		position += 1
	if break_flag == 1:
		break
	ans += N - position + 1
	now -= a[i]
print(ans)


(n, k) = list(map(int, input().split()))
b = list(map(int, input().split()))
sum = 0
d = 0
ans = 0
for i in range(n):
	sum += b[i]
	if sum >= k:
		while sum >= k:
			ans += n - i
			sum -= b[d]
			d += 1
print(ans)


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (N + 1)
r = [0] * (N + 1)
for i in range(N):
	l[i + 1] = l[i] + a[i]
	r[-i - 2] = r[-i - 1] + a[-i - 1]
s = l[-1]
ans = 0
for i in range(N):
	if K > s - r[-i - 1]:
		break
	else:
		c = s - K - r[-i - 1]
		min1 = 0
		max1 = N - i
		while max1 - min1 > 1:
			t = (max1 + min1) // 2
			if l[t] > c:
				max1 = t
			else:
				min1 = t
		ans += min1 + 1
print(ans)


from bisect import bisect_right, bisect_left
(N, K) = map(int, input().split())
A = [0] + list(map(int, input().split()))
prev = 0
for i in range(1, len(A)):
	A[i] = A[i] + A[i - 1]
ans = 0
for i in range(len(A)):
	if A[i] >= K:
		ans += bisect_right(A, A[i] - K)
print(ans)


import bisect
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
sum_A = [0]
for i in range(N):
	sum_A.append(sum_A[i] + A[i])
re_sum_A = [0]
for i in range(N):
	re_sum_A.append(re_sum_A[i] + A[N - 1 - i])
count = 0
maximum = sum_A[N]
for i in range(N):
	num = maximum - K - sum_A[i]
	index = bisect.bisect(re_sum_A, num)
	count = index + count
print(count)


import bisect, collections, copy, itertools, math, string
import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def S():
	return sys.stdin.readline().rstrip()

def LS():
	return list(sys.stdin.readline().rstrip().split())

def main():
	(n, k) = LI()
	a = [0] + LI()
	ac = list(itertools.accumulate(a))
	ans = 0
	now = 0
	for i in range(1, n + 1):
		for j in range(now, n + 1):
			if ac[now] - ac[i - 1] >= k:
				ans += n - now + 1
				break
			else:
				now += 1
		else:
			break
	print(ans)
main()


def main():
	(N, K) = [int(i) for i in input().split()]
	A = [int(i) for i in input().split()]
	(f, b) = (0, 0)
	ans = 0
	v = A[0]
	while f < N:
		if v < K:
			b += 1
			if b == N:
				break
			else:
				v += A[b]
		else:
			ans += N - b
			v -= A[f]
			f += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
left = 0
total = 0
cnt = 0
for right in range(N):
	total += A[right]
	while total >= K:
		cnt += N - right
		total -= A[left]
		left += 1
print(cnt)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(ans, s) = (0, 0)
	r = 0
	for l in range(n):
		while r < n and s < k:
			s += a[r]
			r += 1
		if s >= k:
			ans += n - r + 1
		s -= a[l]
	return ans

def __starting_point():
	print(solve())
__starting_point()


import numpy as np
(N, K) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0, 0)
Acum = np.array(a).cumsum()
(l, r) = (0, 1)
ans = 0
while True:
	if Acum[r] - Acum[l] < K:
		if r < N:
			r += 1
		else:
			l += 1
	if Acum[r] - Acum[l] >= K:
		ans += len(Acum[r:])
		l += 1
	if l == N:
		break
print(ans)


import array
(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
tmp = A[0]
right = 0
for i in range(N):
	for j in range(right + 1, N):
		if tmp >= K:
			break
		tmp += A[j]
		right += 1
	if tmp >= K:
		ans += N - right
		if N - right == 0:
			break
	tmp -= A[i]
print(ans)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
s = [0]
for i in range(N):
	s.append(s[-1] + A[i])
l = 0
r = 1
cnt = 0
for l in range(N):
	while r < N and s[r] - s[l] < K:
		r += 1
	if s[r] - s[l] < K:
		break
	cnt += N - r + 1
	if l + 1 == r:
		r += 1
print(cnt)


def main():
	(N, K) = [int(x) for x in input().split(' ')]
	A = [int(a) for a in input().split(' ')] + [0]
	i = 0
	j = 0
	cnt = [0] * N
	s = A[j]
	while i < N:
		if s < K and j < N - 1:
			j += 1
			s += A[j]
		elif s >= K:
			cnt[i] = N - j
			s -= A[i]
			i += 1
		elif j == N - 1:
			cnt[i] = 0
			s -= A[i]
			i += 1
	print(sum(cnt))
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
left = 0
x = 0
ans = 0
for right in a:
	x += right
	while x >= k:
		x -= a[left]
		left += 1
	ans += left
print(ans)


from itertools import accumulate
import bisect
(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
a = [0] + list(accumulate(lis))
ans = 0
for i in a:
	if i < k:
		continue
	ans += bisect.bisect_right(a, i - k)
print(ans)


from bisect import bisect_right
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
s = [a[0]]
for ai in a[1:]:
	s.append(s[-1] + ai)
ans = 0
for i in range(n):
	if s[i] >= k:
		d = s[i] - k
		ans += bisect_right(s, d) + 1
print(ans)


import bisect
(N, K) = list(map(int, input().split()))
As = list(map(int, input().split()))
as_ruisekiwa = [0]
for a in As:
	as_ruisekiwa.append(a + as_ruisekiwa[-1])
ans = 0
for i in range(N + 1):
	index_check_num = K + as_ruisekiwa[i]
	index = bisect.bisect_left(as_ruisekiwa, index_check_num)
	ans += N - index + 1
print(ans)


from bisect import bisect_left
(N, K) = [int(x) for x in input().split()]
a = [0] + [int(x) for x in input().split()]
s = [0] * (N + 1)
for i in range(1, N + 1):
	s[i] = s[i - 1] + a[i]
ans = 0
for i in range(1, N + 1):
	j = bisect_left(s, K + s[i - 1])
	ans = ans + N - j + 1
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
if n == 1:
	if a[0] >= k:
		print(1)
		return
	else:
		print(0)
		return
right = 0
sum = 0
for left in range(n):
	while right < n and sum < k:
		sum += a[right]
		right += 1
	if sum < k:
		break
	ans += n - right + 1
	if right == left:
		right += 1
	else:
		sum -= a[left]
print(ans)


import itertools
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = itertools.accumulate(a)
(ans, s, j) = (0, 0, 0)
for (i, v) in enumerate(c):
	while v - s >= k:
		ans += n - i
		s += a[j]
		j += 1
print(ans)


(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
(r, total, ans) = (0, 0, 0)
for l in range(N):
	while r < N and total < K:
		total += A[r]
		r += 1
	if total < K:
		break
	ans += N - r + 1
	if l == r:
		r += 1
	else:
		total -= A[l]
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
acsum = [0]
for i in range(n):
	acsum.append(acsum[i] + a[i])
cnt = 0
p = 0
for i in range(n + 1):
	if acsum[i] >= k:
		p = i
		break
if acsum[n] < k:
	pass
else:
	j = 0
	for i in range(p, n + 1):
		while j <= i:
			if acsum[i] - acsum[j] >= k:
				j += 1
				continue
			else:
				cnt += j
				j = j - 1
				break
print(cnt)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
for i in range(1, n):
	l[i] += l[i - 1]
i = 0
j = 0
ans = 0
while j < n:
	if i == 0:
		if k <= l[j]:
			ans += n - j
			i += 1
		else:
			j += 1
	elif k <= l[j] - l[i - 1]:
		ans += n - j
		i += 1
	else:
		j += 1
print(ans)


(N, K) = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
r = 0
l = 0
s = 0
for r in range(N):
	s += A[r]
	while s >= K:
		ans += N - r
		s -= A[l]
		l += 1
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
ans = 0
right = -1
for left in range(n):
	while right < n - 1 and cnt + a[right + 1] < k:
		right = right + 1
		cnt = cnt + a[right]
	if right == n - 1:
		if cnt >= k:
			ans = ans + 1
	elif cnt + a[right + 1] >= k:
		ans = ans + n - right - 1
	cnt = cnt - a[left]
	if right < left:
		right = left - 1
print(ans)


from itertools import accumulate, chain
(N, K) = map(int, input().split())
A = tuple(map(int, input().split()))
j = 0
s = 0
cnt = 0
for i in range(N):
	while j < N and s < K:
		s += A[j]
		j += 1
	if s < K:
		break
	else:
		cnt += N - j + 1
	s -= A[i]
print(cnt)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
from itertools import accumulate
from bisect import bisect_left
a = [0] + list(accumulate(a))
ans = 0
for i in range(n + 1):
	j = bisect_left(a, k + a[i])
	ans = ans + n - j + 1
print(ans)


import math
(n, k) = map(int, input().split())
tmp = 0
cumsum = [0]
for i in map(int, input().split()):
	tmp += i
	cumsum.append(tmp)
total = 0
for end in range(n):
	if cumsum[end + 1] - cumsum[0] >= k:
		tmpstart = 0
		tmpend = end
		tmp = (tmpstart + tmpend) // 2
		while tmpstart != tmpend:
			if cumsum[end + 1] - cumsum[tmp] >= k and cumsum[end + 1] - cumsum[tmp + 1] >= k:
				tmpstart = tmp + 1
			elif cumsum[end + 1] - cumsum[tmp] < k and cumsum[end + 1] - cumsum[tmp + 1] < k:
				tmpend = tmp - 1
			else:
				tmpstart = tmp
				tmpend = tmp
			tmp = (tmpstart + tmpend) // 2
		total += tmp + 1
print(total)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
right = 0
cnt = 0
suma = 0
for left in range(n):
	while right < n and suma + a[right] < k:
		suma += a[right]
		right += 1
	cnt += n - right
	if left == right:
		right += 1
	else:
		suma -= a[left]
print(cnt)


import bisect
(n, k) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
cul_sum = [0] * (n + 1)
for i in range(1, n + 1):
	cul_sum[i] = cul_sum[i - 1] + A[i - 1]
ans = 0
for i in range(n + 1):
	target = k + cul_sum[i]
	right = bisect.bisect_left(cul_sum, target)
	if right == n + 1:
		break
	ans += n - (right - 1)
print(ans)


from itertools import accumulate
from bisect import bisect_left, bisect, bisect_right
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
aa = [0] + list(accumulate(a))
icnt = 0
for i in range(n):
	if aa[i] + k > aa[n]:
		continue
	ii = bisect_left(aa, aa[i] + k)
	icnt += max(n + 1 - ii, 0)
print(icnt)


(N, K, *A) = list(map(int, open(0).read().split()))
total = 0
right = 0
ans = 0
for left in range(N):
	while right < N and total + A[right] < K:
		total += A[right]
		right += 1
	ans += N - right
	if left == right:
		right += 1
	else:
		total -= A[left]
print(ans)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
r = 1
su = A[0]
for left in range(N):
	while su < K:
		if r == N:
			break
		su += A[r]
		r += 1
	if su < K:
		break
	ans += N - r + 1
	su -= A[left]
print(ans)


import sys
入力 = sys.stdin.readline
(範囲, 出力) = (range, print)
一行に複数個の入力 = lambda : map(int, 入力().split())
数列 = list
絶対値 = abs
(長さ, 合計値の下限) = 一行に複数個の入力()
整数列 = 数列(一行に複数個の入力())
累積和 = [0 for _ in 範囲(長さ + 1)]
for _ in 範囲(長さ):
	累積和[_ + 1] = 累積和[_] + 整数列[_]
答え = 0
for _ in 範囲(長さ):
	条件に当てはまる最小値のあるところ = 長さ + 1
	条件に当てはまらない最大値のあるところ = _
	while 絶対値(条件に当てはまる最小値のあるところ - 条件に当てはまらない最大値のあるところ) > 1:
		真ん中 = (条件に当てはまる最小値のあるところ + 条件に当てはまらない最大値のあるところ) // 2
		if 累積和[真ん中] - 累積和[_] >= 合計値の下限:
			条件に当てはまる最小値のあるところ = 真ん中
		else:
			条件に当てはまらない最大値のあるところ = 真ん中
	答え += 長さ + 1 - 条件に当てはまる最小値のあるところ
出力(答え)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(cnt, temp) = (0, a[0])
(head, tail) = (1, 0)
while tail < n:
	if head < n:
		if temp + a[head] < k:
			temp += a[head]
			head += 1
		else:
			if temp < k:
				cnt += head - tail
			temp -= a[tail]
			tail += 1
			if tail == head:
				temp += a[head]
				head += 1
	else:
		if temp < k:
			cnt += head - tail
		tail += 1
print((n + 1) * n // 2 - cnt)


from bisect import bisect_right

def solve(n, k, a):

	def calcCumSum(a):
		l = [0] * (len(a) + 1)
		for i in range(len(a)):
			l[i + 1] = l[i] + a[i]
		return l
	cum = calcCumSum(a)

	def calcSectionSum(cum, left, right):
		return cum[right] - cum[left]
	res = 0
	for left in range(n):
		(ng, ok) = (left, n + 1)
		while abs(ng - ok) > 1:
			mid = (ng + ok) // 2
			if calcSectionSum(cum, left, mid) >= k:
				ok = mid
			else:
				ng = mid
		res += n - ok + 1
	return res

def main():
	(N, K) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(solve(N, K, a))
	return

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
r = 0
sumi = 0
for i in range(0, len(a)):
	while sumi < k:
		if r == len(a):
			break
		else:
			sumi += a[r]
			r += 1
	if sumi < k:
		break
	count += n - r + 1
	sumi -= a[i]
print(count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
acsum = [0]
for i in range(n):
	acsum.append(acsum[i] + a[i])
cnt = 0
jj = 0
for i in range(n):
	for j in range(jj, n - i):
		if acsum[i + j + 1] - acsum[i] >= k:
			cnt += n - i - j
			jj = j - 1
			break
print(cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
sum_a = [0] * (n + 1)
for i in range(1, n + 1):
	sum_a[i] = sum_a[i - 1] + a[i - 1]
sum_a.append(10 ** 11)

def is_ok(mid, now):
	nonlocal k, n, sum_a
	if sum_a[mid] - sum_a[now] >= k:
		return True
	else:
		return False
ans = 0
for i in range(n):
	top = n + 1
	bottom = i
	while top - bottom > 1:
		mid = (top + bottom) // 2
		if is_ok(mid, i):
			top = mid
		else:
			bottom = mid
	ans += n + 1 - top
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
ref = 0
cnt = 0
for i in range(n):
	ref += a[i]
	while ref >= k:
		ref -= a[cnt]
		cnt += 1
	ans += cnt
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
s = 0
start = 0
for i in range(n):
	s += a[i]
	if s >= k:
		ans += n - i
		for j in range(start, i + 1):
			s -= a[j]
			if s >= k:
				ans += n - i
			else:
				start = j + 1
				break
print(ans)


(n, k) = list(map(int, input().split()))
a = [int(i) for i in input().split()]
j = 0
s = 0
c = 0
for i in range(n):
	while j < n and s < k:
		s += a[j]
		j += 1
	if s >= k:
		c += n - j + 1
	s -= a[i]
print(c)


(N, K) = map(int, input().split())
Alist = list(map(int, input().split()))
Slist = [0]
tale = N + 1
for i in range(N):
	try:
		S += Alist[i]
	except:
		S = Alist[i]
	Slist.append(S)
	if S >= K and tale == N + 1:
		tale = i + 1
Ans = N - tale + 1
if Ans != 0:
	for head in range(1, N + 1):
		Sum = Slist[tale] - Slist[head]
		if Sum >= K:
			Ans += N - tale + 1
		elif tale == head and tale < N:
			for _ in range(10 ** 6):
				tale += 1
				Sum = Slist[tale] - Slist[head]
				if Sum >= K:
					Ans += N - tale + 1
					break
				elif tale == N:
					break
		elif tale != N:
			for _ in range(10 ** 6):
				tale += 1
				Sum = Slist[tale] - Slist[head]
				if Sum >= K:
					Ans += N - tale + 1
					break
				elif tale == N:
					break
		if tale > N:
			break
print(Ans)


from itertools import accumulate
import bisect
(N, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
Asum = [0] + list(accumulate(A))
ans = 0
for i in range(1, N + 1):
	ind = bisect.bisect_left(Asum, Asum[i - 1] + K)
	ans += N - ind + 1
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
u = [0]
ui = 0
for i in range(n):
	ui += a[i]
	u.append(ui)
left = 0
right = 1
ans = 0
while right <= n:
	s = u[right] - u[left]
	if s < k:
		right += 1
	else:
		ans += n - right + 1
		left += 1
print(ans)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
S = [0] * (N + 1)
idx = -1
for i in range(N):
	S[i + 1] = S[i] + A[i]
	if idx == -1 and K <= S[i + 1]:
		idx = i + 1
if idx == -1:
	print(0)
else:
	ans = 0
	for i in range(idx, N + 1):
		excess = S[i] - K

		def is_ok(arg):
			return excess < S[arg]

		def meguru_bisect(ng, ok):
			while abs(ok - ng) > 1:
				mid = (ok + ng) // 2
				if is_ok(mid):
					ok = mid
				else:
					ng = mid
			return ok
		ans += meguru_bisect(-1, N + 1)
	print(ans)


(N, K) = list(map(int, input().split()))
a = list(map(int, input().split()))
total = 0
cnt = 0
i = 0
j = 0
while i < N:
	while total < K and j < N:
		total += a[j]
		j = j + 1
	if total >= K:
		cnt += N - j + 1
	total -= a[i]
	i = i + 1
print(cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(r, cnt, tmp) = (0, 0, 0)
for l in range(n):
	while r < n and tmp + a[r] < k:
		tmp += a[r]
		r += 1
	cnt += n - r
	if l == r:
		r += 1
	else:
		tmp -= a[l]
print(cnt)