#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
const ld pi = acos(-1);
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

class segtree {
    int n = 1; VL dat;
#define def 0
public:
    segtree(int _n) {
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
    }
    segtree(VL a) {
        int _n = a.size();
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
        FOR(i, 0, _n)dat[i + n - 1] = a[i];
        rFOR(i, 0, n - 1)dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
    }

    ll fun(ll x, ll y) { return x + y; }

    void update(int i, ll a) {
        i += n - 1;
        dat[i] += a;
        while (i > 0) {
            --i /= 2;
            dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    ll value(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return def;
        if (a <= l && r <= b)return dat[k];
        ll s = value(a, b, 2 * k + 1, l, (l + r) / 2);
        ll t = value(a, b, 2 * k + 2, (l + r) / 2, r);
        return fun(s, t);
    }
    ll value(int a, int b) { return value(a, b, 0, 0, n); }

    ll operator[](int k) { return dat[k + n - 1]; }
};

int main() {
    init();

    int n; ll k; cin >> n >> k;
    VL a(n); cin >> a;

    FOR(i, 0, n)a[i] -= k;
    FOR(i, 0, n - 1)a[i + 1] += a[i];
    map<ll, int> m = { {0,0} };
    FOR(i, 0, n)m[a[i]];
    int cnt = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr) {
        (*itr).second = cnt++;
    }
    VL b(m.size());
    FOR(i, 0, n) {
        a[i] = m[a[i]];
        ++b[a[i]];
    }
    int zero = m[0], Size = m.size();

    segtree seg(b);
    ll ans = seg.value(zero, Size);
    FOR(i, 0, n) {
        seg.update(a[i], -1);
        ans += seg.value(a[i], Size);
    }

    cout << ans << "\n";
}



Measured memory_bytes: 13400