#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>

#define INF 2000000000

using namespace std;

struct info {
	long long val;
	long long leftVal;
	long long rightVal;
	long long leftValSorted;
	long long rightValSorted;
};

int nums[200000];
int n, k;
info arr[200000];
info tmp[200000];
long long ans;

void solve(int l, int r) {
	if (l == r) {
		if (arr[l].val >= 0)
			ans++;
		return;
	}
	int mid = (l + r) / 2;
	solve(l, mid);
	solve(mid + 1, r);
	int leftIndex = l;
	int rightIndex = r;
	while (leftIndex <= mid && rightIndex >= mid + 1) {
		if (arr[leftIndex].rightValSorted + arr[rightIndex].leftValSorted >= 0) {
			ans += mid - leftIndex + 1;
			rightIndex--;	
		}
		else 
			leftIndex++;
	}
	leftIndex = l;
	rightIndex = mid + 1;
	for (int i = l; i <= r; i++) 
		tmp[i].val = arr[i].val;
	for (int i = l; i <= mid; i++)
		tmp[i].leftVal = arr[i].leftVal;
	for (int i = mid + 1; i <= r; i++)
		tmp[i].leftVal = arr[mid].leftVal + arr[i].leftVal;
	for (int i = r; i >= mid + 1; i--)
		tmp[i].rightVal = arr[i].rightVal;
	for (int i = mid; i >= l; i--) 
		tmp[i].rightVal = arr[mid + 1].rightVal + arr[i].rightVal;
	while (leftIndex <= mid || rightIndex <= r) {
		if (leftIndex > mid) {
			tmp[leftIndex + rightIndex - (mid + 1)].leftValSorted = arr[mid].leftVal + arr[rightIndex++].leftValSorted;
		}
		else if (rightIndex > r) {
			tmp[leftIndex + rightIndex - (mid + 1)].leftValSorted = arr[leftIndex++].leftValSorted;
		}
		else {
			if (arr[leftIndex].leftValSorted <= arr[mid].leftVal + arr[rightIndex].leftValSorted)
				tmp[leftIndex + rightIndex - (mid + 1)].leftValSorted = arr[leftIndex++].leftValSorted;
			else
				tmp[leftIndex + rightIndex - (mid + 1)].leftValSorted = arr[mid].leftVal + arr[rightIndex++].leftValSorted;			
		}
	}
	leftIndex = l;
	rightIndex = mid + 1;
	while (leftIndex <= mid || rightIndex <= r) {
		if (leftIndex > mid) {
			tmp[leftIndex + rightIndex - (mid + 1)].rightValSorted = arr[rightIndex++].rightValSorted;
		}
		else if (rightIndex > r) {
			tmp[leftIndex + rightIndex - (mid + 1)].rightValSorted = arr[mid + 1].rightVal + arr[leftIndex++].rightValSorted;
		}
		else {
			if (arr[leftIndex].rightValSorted + arr[mid + 1].rightVal <= arr[rightIndex].rightValSorted)
				tmp[leftIndex + rightIndex - (mid + 1)].rightValSorted = arr[leftIndex++].rightValSorted + arr[mid + 1].rightVal;
			else
				tmp[leftIndex + rightIndex - (mid + 1)].rightValSorted = arr[rightIndex++].rightValSorted;			
		}
	}
	for (int i = l; i <= r; i++)
		arr[i] = tmp[i];
	// cout << l << " " << r << endl;
	// for (int i = l; i <= r; i++) 
	// 	cout << arr[i].val << " ";
	// cout << endl << "-----" << endl;
	// for (int i = l; i <= r; i++) 
	// 	cout << arr[i].leftVal << " ";
	// cout << endl << "-----" << endl;
	// for (int i = l; i <= r; i++) 
	// 	cout << arr[i].leftValSorted << " ";
	// cout << endl << "-----" << endl;
	// for (int i = l; i <= r; i++) 
	// 	cout << arr[i].rightVal << " ";
	// cout << endl << "-----" << endl;
	// for (int i = l; i <= r; i++) 
	// 	cout << arr[i].rightValSorted << " ";
	// cout << endl << "-----" << endl;
	// cout << "^^^^^^^^^^^^^^^^" << endl;
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", nums + i);
		nums[i] -= k;
		arr[i].val = arr[i].leftVal = arr[i].rightVal = arr[i].leftValSorted = arr[i].rightValSorted = nums[i];
	}
	solve(0, n - 1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 16640