思路:不定长滑动窗口,越长越合法。模板题,建议没学过不定长滑动窗口,越长越合法的同学好好练习一下

代码:

import sys
input = lambda: sys.stdin.readline().strip()

import math
inf = 10 ** 18

def I():
    return input()

def II():
    return int(input())

def MII():
    return map(int, input().split())

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

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

def LFI():
    return list(map(float, input().split()))

fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))

'''

'''

def solve():
    n, k = MII()
    a = LII()

    ans = 0
    l = s = 0
    for r, x in enumerate(a):
        s += x
        while s >= k:
            s -= a[l]
            l += 1
        ans += l
    print(ans)

t = 1
# t = II()
for _ in range(t):
    solve()