class BIT():

    def __init__(self,size):

        self.size=size

        self.node=[0]*(size+1)



    def sum(self,idx):

        ret=0

        while idx>0:

            ret+=self.node[idx]

            idx-=idx&(-idx)

        return ret



    def add(self,idx,x):

        while idx<=self.size:

            self.node[idx]+=x

            idx+=idx&(-idx)



n,k=list(map(int,input().split()))

a=[int(input()) for _ in range(n)]

diff=[]

for i in range(n):

    diff.append(a[i]-k)

for i in range(n-1):

    diff[i+1]+=diff[i]

bit=BIT(n)

s=set([])

for i in range(n):

    bit.add(i+1,1)

    s.add(diff[i])

li=list(s)

li.sort()

d={}

for i in range(len(li)):

    d[li[i]]=i

pos=[[] for _ in range(len(li))]

for i in range(n):

    idx=d[diff[i]]

    pos[idx].append(i+1)

ans=0

for i in range(len(li)):

    for j in pos[i]:

        ans+=bit.sum(n)-bit.sum(j)

        if diff[j-1]>=0:

            ans+=1

        bit.add(j,-1)

print(ans)

class BIT():

    def __init__(self,size):

        self.size=size

        self.node=[0]*(size+1)



    def sum(self,idx):

        ret=0

        while idx>0:

            ret+=self.node[idx]

            idx-=idx&(-idx)

        return ret



    def add(self,idx,x):

        while idx<=self.size:

            self.node[idx]+=x

            idx+=idx&(-idx)



n,k=list(map(int,input().split()))

a=[int(input()) for _ in range(n)]

diff=[]

for i in range(n):

    diff.append(a[i]-k)

for i in range(n-1):

    diff[i+1]+=diff[i]

bit=BIT(n)

s=set([])

for i in range(n):

    s.add(diff[i])

li=list(s)

li.sort()

d={}

for i in range(len(li)):

    d[li[i]]=i+1

ans=0

for i in range(n):

    pos=d[diff[i]]

    ans+=bit.sum(pos)

    if diff[i]>=0:

        ans+=1

    bit.add(pos,1)

print(ans)

class BIT:
    def __init__(self, size):
        self.size = size
        self.node = [0] * (size + 1)

    def sum(self, idx):
        ret = 0
        while idx > 0:
            ret += self.node[idx]
            idx -= idx & (-idx)
        return ret

    def add(self, idx, x):
        while idx <= self.size:
            self.node[idx] += x
            idx += idx & (-idx)


n, k = list(map(int, input().split()))
a = [int(input()) for _ in range(n)]
diff = []
for i in range(n):
    diff.append(a[i] - k)
for i in range(n - 1):
    diff[i + 1] += diff[i]
bit = BIT(n)
s = set([])
for i in range(n):
    bit.add(i + 1, 1)
    s.add(diff[i])
li = list(s)
li.sort()
d = {}
for i in range(len(li)):
    d[li[i]] = i
pos = [[] for _ in range(len(li))]
for i in range(n):
    idx = d[diff[i]]
    pos[idx].append(i + 1)
ans = 0
for i in range(len(li)):
    for j in pos[i]:
        ans += bit.sum(n) - bit.sum(j)
        if diff[j - 1] >= 0:
            ans += 1
        bit.add(j, -1)
print(ans)

class BIT:
    def __init__(self, size):
        self.size = size
        self.node = [0] * (size + 1)

    def sum(self, idx):
        ret = 0
        while idx > 0:
            ret += self.node[idx]
            idx -= idx & (-idx)
        return ret

    def add(self, idx, x):
        while idx <= self.size:
            self.node[idx] += x
            idx += idx & (-idx)


n, k = list(map(int, input().split()))
a = [int(input()) for _ in range(n)]
diff = []
for i in range(n):
    diff.append(a[i] - k)
for i in range(n - 1):
    diff[i + 1] += diff[i]
bit = BIT(n)
s = set([])
for i in range(n):
    s.add(diff[i])
li = list(s)
li.sort()
d = {}
for i in range(len(li)):
    d[li[i]] = i + 1
ans = 0
for i in range(n):
    pos = d[diff[i]]
    ans += bit.sum(pos)
    if diff[i] >= 0:
        ans += 1
    bit.add(pos, 1)
print(ans)

-    bit.add(i + 1, 1) -    d[li[i]] = i -pos = [[] for _ in range(len(li))] +    d[li[i]] = i + 1 +ans = 0 -    idx = d[diff[i]] -    pos[idx].append(i + 1) -ans = 0 -for i in range(len(li)): -    for j in pos[i]: -        ans += bit.sum(n) - bit.sum(j) -        if diff[j - 1] >= 0: -            ans += 1 -        bit.add(j, -1) +    pos = d[diff[i]] +    ans += bit.sum(pos) +    if diff[i] >= 0: +        ans += 1 +    bit.add(pos, 1)