// 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: 14.740507370725219x):
#include<cstdio>

#include<algorithm>

#define ll long long

using namespace std;



const int N=4e5+5;

int n,k,now,c[N],b[N];

ll s,ans;

struct A{ ll x; int id; }a[N];



bool cmp(A i,A j) {

    return i.x<j.x;

}



inline void add(int x) {

    for(int i=x;i<=now;i+=i&-i) {

        c[i]++;

    }

}



inline int ask(int x) {

    int ret=0;

    for(int i=x;i;i-=i&-i) {

        ret+=c[i];

    }

    return ret;

}



int main() {

    scanf("%d%d",&n,&k);

    a[0]=(A){0,0};

    for(int i=1;i<=n;i++) {

        int x; scanf("%d",&x);

        s+=x;

        a[i]=(A){s-(ll)k*i,i};

    }

    sort(a,a+n+1,cmp);

    b[a[0].id]=now=1;

    for(int i=1;i<=n;i++) {

        if(a[i].x!=a[i-1].x) {

            now++;

        }

        b[a[i].id]=now;

    }

    for(int i=0;i<=n;i++) {

        ans+=ask(b[i]),add(b[i]);

    }

    printf("%lld\n",ans);

    return 0;

}