#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct data{
	ll v;
	int n;
}b[510001];
ll ans,s[510001];
int i,j,k,n,m,a[510001],c[510001],p[510001];
bool cmp(data x,data y){
	return x.v<y.v;
}
void change(int x,int v){
	for (;x<=n+1;x+=x&(-x)) c[x]+=v;
}
int query(int x){
	int res=0;
	for (;x;x-=x&(-x)) res+=c[x];
	return res;
}
int main(){
	scanf("%d%d",&n,&m);memset(c,0,sizeof(c));
	for (i=1,s[0]=0;i<=n;i++) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for (i=0;i<=n;i++) b[i+1].n=i,b[i+1].v=s[i]-(ll)m*(ll)i;
	sort(b+1,b+2+n,cmp);
	for (i=1,k=0;i<=n+1;i++){
		if (i==1||b[i-1].v!=b[i].v) k++;
		p[b[i].n]=k;
	}
	for (ans=i=0;i<=n;i++){
		ans+=query(p[i]);
		change(p[i],1);
	}
	printf("%lld\n",ans);
	return 0;
}