Problem: K Average Ranges

Given the sequence a_1, a_2, .., a_N.

How many intervals in this sequence have an average value of K or more and a length of 1 or more?

input


N K
a_1 a_2 ... a_N


output

Output the answer.

Constraint

* 1 \ leq N \ leq 10 ^ 5
* 1 \ leq K \ leq 10 ^ 9
* 1 \ leq a_i \ leq 10 ^ 9



Input example


6 6
8 6 9 1 2 1


Output example


7






Example

Input

6 6
8 6 9 1 2 1


Output

7

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct BinaryIndexedTree {
private:
    int n,b;
    vector<int> bit;
public:
    BinaryIndexedTree(int n_) {
        n = n_+10;
        b = 1;
        while (b < n) b <<= 1;
        b >>= 1;
        bit = vector<int>(n,0);
    }

    void add(int a,int w) {
        a++;
        for (int x = a;x < n;x += x&-x) bit[x] += w;
    }

    int sum(int a) {
        a++;
        int ret = 0;
        for (int x = a;x > 0;x -= x&-x) ret += bit[x];
        return ret;
    }

    void update(int a,int w) {
        a++;
        int v = w-sum(a)+sum(a-1);
        add(a,v);
    }

    int lower_bound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = b;k > 0;k /= 2) {
            if (x+k < n && bit[x+k] < w) {
                w -= bit[x+k];
                x += k;
            }
        }
        return x;
    }
};

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> a(n),sums(n+1,0);
    BinaryIndexedTree bit(2*n+1);
    map<ll,int> mp;
    for (int i = 0;i < n;++i) cin >> a[i],a[i] -= k,sums[i+1] = sums[i]+a[i];
    for (int i = 0;i < n+1;++i) mp[sums[i]] = 0;
    {
        int j = 0;
        auto it = mp.find(0);
        for (;it != mp.end();++it) it->second = j,j++;
        j = 0;
        it = mp.find(0);
        for (;;--it) {
            it->second = j;
            j--;
            if (it == mp.begin()) break;
        }
    }
    ll ans = 0;
    for (int i = 0;i < n+1;++i) {
        ans += bit.sum(mp[sums[i]]+n);
        bit.add(mp[sums[i]]+n,1);
    }
    cout << ans << endl;
}