#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int64_t N, K;
V<int64_t> A;

int64_t naive() {
	int64_t ans = 0;
	for (int i = 0; i < N; ++i) {
		int64_t s = 0;
		for (int j = i; j < N; ++j) {
			s += A[j];
			if (s >= K*(j-i+1)) {
				++ans;
			}
		}
	}
	return ans;
}


template <typename AVLKeyT>
struct AVLTree {
	struct node {
		AVLKeyT key;
		// Height of subtree, size of subtree, number of duplicate keys for this key.
	    int height, size, count;
	    node* left, *right;
	    node(AVLKeyT k) { key = k; left = right = nullptr; height = size = count = 1; }
	    ~node() { delete left; delete right; }
	};
	node* root = nullptr;
	~AVLTree() { delete root; }

	int height(node* p) { return p ? p->height : 0; }

	int size(node* p) { return p ? p->size : 0; }

	int bfactor(node* p) { return height(p->right)-height(p->left); }

	void fixheight(node* p) {
	    int hl = height(p->left), hr = height(p->right);
	    p->height = ( hl>hr ? hl : hr) + 1;
	    p->size = p->count + size(p->left) + size(p->right);
	}

	node* rotateright(node* p) {
	    node* q = p->left;
	    p->left = q->right;
	    q->right = p;
	    fixheight(p); fixheight(q);
	    return q;
	}

	node* rotateleft(node* q) {
	    node* p = q->right;
	    q->right = p->left;
	    p->left = q;
	    fixheight(q); fixheight(p);
	    return p;
	}

	node* balance(node* p) { // balancing the p node
	    fixheight(p);
	    if (bfactor(p)==2 ) {
	        if (bfactor(p->right) < 0)
	            p->right = rotateright(p->right);
	        return rotateleft(p);
	    }
	    if (bfactor(p)==-2) {
	        if (bfactor(p->left) > 0 )
	            p->left = rotateleft(p->left);
	        return rotateright(p);
	    }
	    return p; // balancing is not required
	}

	node* insert(node* p, AVLKeyT k) { // insert k key in a tree with p root
	    if (!p) return new node(k);
	    if (p->key == k) {
	    	++p->count;
	    	++p->size;
	    }
	    else if (k <= p->key) 
	    	p->left = insert(p->left, k);
	    else 
	    	p->right = insert(p->right, k);
	    return balance(p);
	}

	void Insert(AVLKeyT k) { root = insert(root, k); }

	node* findmin(node* p) { // find a node with minimal key in a p tree 
	    return p->left?findmin(p->left):p;
	}

	node* removemin(node* p) { // deleting a node with minimal key from a p tree
	    if (p->left==0)
	        return p->right;
	    p->left = removemin(p->left);
	    return balance(p);
	}

	node* remove(node* p, AVLKeyT k) { // deleting k key from p tree
	    if (p == nullptr) return nullptr;
	    if (k < p->key)
	        p->left = remove(p->left,k);
	    else if (k > p->key)
	        p->right = remove(p->right,k);  
	    else { //  k == p->key 
	    	if (p->count > 1) {
	    		--p->count;
	    		--p->size;
	    		return balance(p);
	    	}
	        node* q = p->left; p->left = nullptr;
	        node* r = p->right; p->right = nullptr;
	        delete p;
	        if (!r) return q;
	        node* min = findmin(r);
	        min->right = removemin(r);
	        min->left = q;
	        return balance(min);
	    }
	    return balance(p);
	}

	void Remove(AVLKeyT k) { root = remove(root, k); }

	int CountGreater(node* p, AVLKeyT k) {
		if (p == nullptr)
			return 0;
		if (k == p->key)
			return size(p->right);
		else if (k < p->key)
			return CountGreater(p->left, k) + size(p->right) + p->count;
		else 
			return CountGreater(p->right, k);
	}

	int CountGreater(AVLKeyT k) { return CountGreater(root, k); }

	void Print(node* p) {
		if (p == nullptr) 
			return;
		Print(p->left);
		cout << p->key << " ";
		Print(p->right);
	}

	void GetElements(node* p, multiset<int> &elems) {
		if (p == nullptr) 
			return;
		GetElements(p->left, elems);
		for (int i = 0; i < p->count; ++i)
			elems.insert(p->key);
		GetElements(p->right, elems);
	}

};

int64_t solve() {
	AVLTree<int64_t> t;
	t.Insert(0);
	int64_t S = 0, cnt = 0;
	for (int i = 0; i < N; ++i) {
		S += A[i];
		int64_t rhs = K*(i+1)-S;
		// cout << i << " " << rhs << " " << st.query(rhs, 1e18) << endl; 
		cnt += t.CountGreater(rhs-1);
		t.Insert(rhs);
	}
	return cnt;
}

void test() {
	default_random_engine re;
	for (int tc = 0; tc < 1000; ++tc) {

	}
}

int main() {
	cin >> N >> K;
	A = V<int64_t>(N);
	READALL(A);
	// cout << naive() << endl;
	cout << solve() << endl;
}

Measured memory_bytes: 11136