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

#include<algorithm>

int n, k;

long long ans;

long long c[200010], val[200010], sum[200010];



inline void add(long long x, long long y){

	for(;x <= n;x += x & -x) c[x] += y;

}



inline long long ask(long long x){

	long long ans = 0;

	for(;x;x -= x & -x) ans += c[x];

	return ans;

}



int main(){

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

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

		scanf("%lld", &val[i]);

		val[i] -= k; 

	}

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

		sum[i] = (val[i] += val[i - 1]);

		if (sum[i] >= 0) ++ans;

	}

	std::sort(sum + 1, sum + 1 + n);int t = std::unique(sum + 1, sum + 1 + n) - (sum + 1);

	for(int i = 1;i <= n;++i) val[i] = std::lower_bound(sum + 1, sum + 1 + t, val[i]) - sum;

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

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

	}

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

	return 0;

}

/*

对区间[l, r] average = (sum[r] - sum[l - 1]) / (r - l + 1) >= k

等价于sum[r]-r*k>=sum[l-1]-(l-1)*k

*/