// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>

#include<stack>

#include<string>

#include<cmath>

#include<algorithm>

#include<bitset>

#include<map>

#include<unordered_map>

#include<functional>

#include<set>

#include<numeric>

 

#pragma region

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)

#define rep(i,n) FOR(i,0LL,n)

#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)

#define rrep(i,n) RFOR(i,0LL,n)

#define all(x) x.begin(),x.end()

#define rall(x) x.rbegin(),x.rend()

#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)

#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())

#define SUM(a) accumulate(all(a),0LL)

#define pb push_back

#define endl '\n'

typedef long long int ll;

typedef vector<ll> vll;

typedef vector<vll> vvll;

typedef pair<ll, ll> pll;

typedef vector<pll> vpll;

typedef vector<string> vs;

typedef map<ll, ll> MAP;

const ll inf = 2222222222222222222LL;

const ll mod = 1000000007LL;

 

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;

string s;

bool ok = true, flag = false;

ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };

ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };

#pragma endregion

#define MAX 222222

 

 

struct BinaryIndexed {

	ll num;

	vll bit;

 

	BinaryIndexed(ll x = MAX) {

		num = x;

		bit.resize(x + 1, 0);

	}

 

	ll sum(ll i) {

		ll ret = 0;

		while (i > 0) {

			ret += bit[i];

			i -= i & -i;

		}

		return ret;

	}

 

	void add(ll i, ll x) {

		if (i == 0) cout << "access 0 index" << endl;

		while (i <= num) {

			bit[i] += x;

			i += i & -i;

		}

	}

};

 

ll a[MAX], b[MAX];

 

int main(void) {

	ios::sync_with_stdio(false);

	cin.tie(0);

 

 

	cin >> n >> m;

	FOR(i, 1, n + 1) {

		cin >> a[i];

	}

	FOR(i, 1, n + 1) b[i] = b[i - 1] + a[i];

	FOR(i, 1, n + 1) b[i] = i * m - b[i];

	vll v;

	FOR(i, 1, n + 1) v.pb(b[i]);

	sort(all(v));

	MAP comp;

	rep(i, n) comp[v[i]] = i + 1;

	BinaryIndexed bit;

	FOR(i, 1, n + 1) {

		if (comp[b[i]] > 1) ans += (i - 1) - bit.sum(comp[b[i]] - 1);

		else ans += i - 1;

		if (b[i] <= 0) ans++;

		bit.add(comp[b[i]], 1);

	}

	cout << ans << endl;

 

 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.860252478232605x):
#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#define int long long

#define rint register int

using namespace std;

const int maxn=2e5+5;

inline int read()

{

	int x=0,f=1;

	char ch=getchar();

	while(ch<'0'||ch>'9')

	{

		if(ch=='-') f=-1;

		ch=getchar();

	}

	while(ch>='0'&&ch<='9')

	{

		x=x*10+ch-'0';

		ch=getchar();

	}

	return x*f;

}

int n,k;

int a[maxn];

int sum[maxn];

int ans;

int c[maxn];

inline void msort(int l,int r)

{

	if(l==r)

	return ;

	int mid=(l+r)>>1;

	msort(l,mid);

	msort(mid+1,r);

	int i=l,j=mid+1,k=l;

	while(i<=mid&&j<=r)

	{

		if(a[i]<=a[j])

		{

			ans+=r-j+1;

			c[k++]=a[i++];

		}

		else

		c[k++]=a[j++];

	}

	while(i<=mid)

	c[k++]=a[i++];

	while(j<=r)

	c[k++]=a[j++];

	for(int i=l;i<=r;i++)

	a[i]=c[i];

}

signed main()

{

	n=read()+1;

	k=read();

	for(rint i=2;i<=n;i++)

	{

		a[i]=read();

		sum[i]=sum[i-1]+a[i];

		a[i]=sum[i]-k*(i-1);

	}

	msort(1,n);

	cout<<ans;

}