#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1000000009
#define init(x) memset(x,0,sizeof(x))
template <class T>
struct treap{//  small-root heap, multi treap
    struct node{//i
        node *left,*right;
        T value;
        int fix,weight,size;// 修正值，重复计数，子树大小（conclusive）
        inline int lsize(){return left? left->size:0;}
        inline int rsize(){return right? right->size:0;}
    };
    node *root=0;
    inline void build_node(node *&p,T value,int fix){//i
        p = new node;
        p->left = p->right = 0;
        p->value = value;
        p->fix = fix;
        p->weight = 1;
        p->size = 1;
    }
    inline void left_rotate(node *&p){//i
        node *temp = p->right;
        p->right = temp->left;
        temp->left = p;
        p = temp;
        temp = p->left;
        temp->size = temp->lsize() + temp->rsize() + temp->weight;
        p->size = p->lsize() + p->rsize() + p->weight;
    }
    inline void right_rotate(node *&p){//i
        node *temp = p->left;
        temp->size = temp->lsize() + temp->rsize() + temp->weight + p->rsize() + p->weight;
        p->left = temp->right;
        temp->right = p;
        p = temp;
        temp = p->right;
        temp->size = temp->lsize() + temp->rsize() + temp->weight;
    }
    inline bool empty(){return !root;}//out
    inline int size(){return root->size;}//out
    inline void insert(T value){insert(root,value);}//out
    inline void insert(node *&p,T value){//i
        if (!p){build_node(p,value,rand());return;}
        else if ( value < p->value ){
            insert(p->left,value);
            ++p->size;
            if ( p->left->fix < p->fix ) right_rotate(p);
        }
        else if ( value > p->value ){
            insert(p->right,value);
            ++p->size;
            if ( p->right->fix < p->fix ) left_rotate(p);
        }
        else if ( value == p->value ){++p->weight;++p->size;}
    }
    inline node* find(T value){return find(root,value);}//out
    inline node* find(node *p,T value){//i
        if (!p) return 0;
        if ( value == p->value ) return p;
        if ( value < p->value ) return find(p->left,value);
        if ( value > p->value ) return find(p->right,value);
    }
    inline void erase(T value){erase(root,value);}//out
    inline void erase(node *&p,T value){//i
        if (!p) return;
        if ( value == p->value ){
        	//cerr<<"FOUND ELEMENT"<<endl; 
            if ( p->weight > 1 ){-- p->weight; -- p->size;return;}
            else if ( !p->left && !p->right ){delete p;p=0;}
            else if ( !p->left ){node* t = p->right;delete p;p = t;}
            else if ( !p->right ){node* t = p->left;delete p;p = t;}
            else{
                if ( p->left->fix < p->right->fix ){
                    right_rotate(p);
                    erase(p->right,value);
                }
                else{
                    left_rotate(p);
                    erase(p->left,value);
                }
            }
        }
        else if ( value < p->value ){
        	//cerr<<"CURRENT VALUE:"<< p->value.S <<"	LESS"<<endl;
            erase(p->left,value);
            -- p->size;
        }
        else if ( value > p->value ){
        	//cerr<<"CURRENT VALUE:"<< p->value.S <<"	GREATER"<<endl;
            erase(p->right,value);
            -- p->size;
        }
    }
    inline T min(){return min(root);}//out
    inline T min(node *p){//i
        if (!p->left) return p->value;
        else return min(p->left);
    }
    inline T max(){return max(root);}//out
    inline T max(node *p){//i
        if (!p->right) return p->value;
        else return max(p->right);
    }
    inline node* pre(T value){return pre(root,value,0);}//out
    inline node* pre(node *p,T value,node *optimal){//i
        if (!p) return optimal;
        if ( p->value <= value ) return pre(p->right,value,p);
        else return pre(p->left,value,optimal);
    }
    inline node* suc(T value){return suc(root,value,0);}//out
    inline node* suc(node *p,T value,node *optimal){//i
        if (!p) return optimal;
        if ( p->value >= value ) return suc(p->right,value,p);
        else return suc(p->left,value,optimal);
    }
    inline node* pre_s(T value){return pre_s(root,value,0);}//out
    inline node* pre_s(node *p,T value,node *optimal){//in,strictl
        if (!p) return optimal;
        if ( p->value < value ) return pre_s(p->right,value,p);
        else return pre_s(p->left,value,optimal);
    }
    inline node* suc_s(T value){return suc_s(root,value,0);}//out
    inline node* suc_s(node *p,T value,node *optimal){//in,strictl
        if (!p) return optimal;
        if ( p->value > value ) return suc_s(p->right,value,p);
        else return suc_s(p->left,value,optimal);
    }
    inline node* query(int rk){return query(root,rk);}//out
    inline node* query(node *p,int rk){//i
        if ( rk < p->lsize()+1 ){
        	//cout<<"CUR:"<<p->value<<"	LEFT"<<endl;
			return query(p->left,rk);
		}
        else if ( rk > p->lsize() + p->weight ){
        	//cout<<"CUR:"<<p->value<<"	RIGHT"<<endl;
			return query(p->right,rk - p->lsize() - p->weight);
		}
        else return p;
    }
    inline int rank(T value){return rank(root,value,0);}//out
    inline int rank(node *p,T value,int cur){//in,start from 
        if ( value == p->value ){
        	return p->lsize() + cur;
		}
        else if ( value < p->value ){
        	return rank(p->left,value,cur);
		}
        else return rank(p->right,value,cur + p->lsize() + p->weight);
    }
    inline void print(){print(root);}//out,debug,first_traverse
    inline void print(node *p){//i
    	if (!p) return;
    	cout<<"VAL:"<<p->value<<"	WGT:"<<p->weight<<endl;
		cout<<"Lsize:"<<p->lsize()<<"	Rsize:"<<p->rsize()<<"	SIZE:"<<p->size;
		cout<<"	L:";
		if (p->left) cout<<p->left->value;
		else cout<<"NULL";
		cout<<"	R:";
		if (p->right) cout<<p->right->value;
		else cout<<"NULL";
		cout<<endl;
		print(p->left);
		print(p->right);
	}
};
ll n,k,p=1,ans=0;
ll a[200005],s[200005];
treap<ll> trp;
vl v;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for (int i=1;i<=n;++i){
        cin>>a[i];a[i]-=k;s[i]=s[i-1]+a[i];v.pb(s[i]);
    }
    v.pb(0);
    sort(v.begin(),v.end());
    for (int i=0;i<=n;++i) a[i]=lower_bound(v.begin(),v.end(),s[i])-v.begin()+1;
    trp.insert(a[0]);
    for (int i=1;i<=n;++i){
        auto cur=trp.pre(a[i]);
        if (cur) ans+=cur->weight+trp.rank(cur->value);
        trp.insert(a[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 14320