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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second

string DBG_DLM(int &i){return(i++==0?"":", ");}
#define DBG_B(exp){int i=0;os<<"{";{exp;}os<<"}";return os;}
template<class T>ostream&operator<<(ostream&os,vector<T>v);
template<class T>ostream&operator<<(ostream&os,set<T>v);
template<class T>ostream&operator<<(ostream&os,queue<T>q);
template<class T>ostream&operator<<(ostream&os,priority_queue<T>q);
template<class T,class K>ostream&operator<<(ostream&os,pair<T,K>p);
template<class T,class K>ostream&operator<<(ostream&os,map<T,K>mp);
template<class T,class K>ostream&operator<<(ostream&os,unordered_map<T,K>mp);
template<int I,class TPL>void DBG(ostream&os,TPL t){}
template<int I,class TPL,class H,class...Ts>void DBG(ostream&os,TPL t){os<<(I==0?"":", ")<<get<I>(t);DBG<I+1,TPL,Ts...>(os,t);}
template<class T,class K>void DBG(ostream&os,pair<T,K>p,string delim){os<<"("<<p.first<<delim<<p.second<<")";}
template<class...Ts>ostream&operator<<(ostream&os,tuple<Ts...>t){os<<"(";DBG<0,tuple<Ts...>,Ts...>(os,t);os<<")";return os;}
template<class T,class K>ostream&operator<<(ostream&os,pair<T,K>p){DBG(os,p,", ");return os;}
template<class T>ostream&operator<<(ostream&os,vector<T>v){DBG_B(forr(t,v){os<<DBG_DLM(i)<<t;});}
template<class T>ostream&operator<<(ostream&os,set<T>s){DBG_B(forr(t,s){os<<DBG_DLM(i)<<t;});}
template<class T>ostream&operator<<(ostream&os,queue<T>q){DBG_B(for(;q.size();q.pop()){os<<DBG_DLM(i)<<q.front();});}
template<class T>ostream&operator<<(ostream&os,priority_queue<T>q){DBG_B(for(;q.size();q.pop()){os<<DBG_DLM(i)<<q.top();});}
template<class T,class K>ostream&operator<<(ostream&os,map<T,K>m){DBG_B(forr(p,m){os<<DBG_DLM(i);DBG(os,p,"->");});}
template<class T,class K>ostream&operator<<(ostream&os,unordered_map<T,K>m){DBG_B(forr(p,m){os<<DBG_DLM(i);DBG(os,p,"->");});}
#define DBG_OVERLOAD(_1,_2,_3,_4,_5,_6,macro_name,...)macro_name
#define DBG_LINE(){char s[99];sprintf(s,"line:%3d | ",__LINE__);cerr<<s;}
#define DBG_OUTPUT(v){cerr<<(#v)<<"="<<(v);}
#define DBG1(v,...){DBG_OUTPUT(v);}
#define DBG2(v,...){DBG_OUTPUT(v);cerr<<", ";DBG1(__VA_ARGS__);}
#define DBG3(v,...){DBG_OUTPUT(v);cerr<<", ";DBG2(__VA_ARGS__);}
#define DBG4(v,...){DBG_OUTPUT(v);cerr<<", ";DBG3(__VA_ARGS__);}
#define DBG5(v,...){DBG_OUTPUT(v);cerr<<", ";DBG4(__VA_ARGS__);}
#define DBG6(v,...){DBG_OUTPUT(v);cerr<<", ";DBG5(__VA_ARGS__);}
#define DEBUG0(){DBG_LINE();cerr<<endl;}
#ifdef LOCAL
#define out(...){DBG_LINE();DBG_OVERLOAD(__VA_ARGS__,DBG6,DBG5,DBG4,DBG3,DBG2,DBG1)(__VA_ARGS__);cerr<<endl;}
#else
#define out(...)
#endif

template<class T,class K>istream&operator>>(istream&is,pair<T,K>&p){is>>p.fst;is>>p.snd;return is;}
template<class T>istream&operator>>(istream&is,vector<T>&v){forr(e,v)is>>e;return is;}
#define rea(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<class T>void MACRO_VAR_Scan(T&t){cin>>t;}
template<class H,class...Ts>void MACRO_VAR_Scan(H&h,Ts&...ts) {cin>>h;MACRO_VAR_Scan(ts...);}
#define rea_vecs(type,n,...)vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n,__VA_ARGS__);rep(i,n)MACRO_VEC_ROW_Scan(i,__VA_ARGS__);
template<class T>void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); }
template<class H,class...Ts>void MACRO_VEC_ROW_Init(int n,H&h,Ts&...ts){h.resize(n);MACRO_VEC_ROW_Init(n,ts...);}
template<class T>void MACRO_VEC_ROW_Scan(int p,T&t){cin>>t[p];}
template<class H,class...Ts>void MACRO_VEC_ROW_Scan(int p,H&h,Ts&...ts){cin>>h[p];MACRO_VEC_ROW_Scan(p,ts...);}
#define rea_vec(type,n,c) vector<type>c(n);cin>>c;

using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T>bool amax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>bool amin(T&a,const T&b){return a>b?a=b,1:0;}
ll ri(){ll l;cin>>l;return l;} string rs(){string s;cin>>s;return s;}

template <class Val>
struct Treap {
  struct Node {
    static Val comp(const Val& l, const Val& r) { return min(l, r); }; // for Range Min Query
    // static Val comp(const Val& l, const Val& r) { return max(l, r); };  // for Range Max Query
    // static Val comp(const Val& l, const Val& r) { return l + r; };  // for Range Sum Query

    Val v;
    int priority;
    Node *lef, *rig;
    int size_;   // 部分木のサイズ
    Val summary; // 部分木の値をまとめたもの(sum, min, max, etc)

    Node() {}
    Node(Val v) : v(v), priority(xor128()), lef(nullptr), rig(nullptr), size_(1), summary(v) {}

    void *operator new(std::size_t) {
      static Node pool[500010];
      static int p = 0;
      return pool + p++;
    }

    int size() const { return size_;}
    string to_string() const { string res; to_string(res); return res; }

    void to_string(string &res) const {
      res += "Node [v="; res += std::to_string(v);
      res += ", size="; res += std::to_string(size_);
      res += "]";
    }

    static int xor128() {
      static random_device rnd;
      static int x = 123456789, y = 362436069, z = 521288629, w = rnd();
      int t = x ^ (x << 11);
      x = y;
      y = z;
      z = w;
      w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
      return w;
    }

    static void to_string(const Node* a, string &res, int indent) {
      if (a == nullptr) return;
      to_string(a->lef, res, indent + 2);
      for (int i = 0; i < indent; i++) res += ' ';
      a->to_string(res);
      res += '\n';
      to_string(a->rig, res, indent + 2);
    }

    static Node* update(Node* a) {
      if (a == nullptr) return nullptr;
      a->size_ = 1 + size(a->lef) + size(a->rig);

      a->summary = a->v;
      if (a->lef != nullptr) a->summary = comp(a->summary, a->lef->summary);
      if (a->rig != nullptr) a->summary = comp(a->summary, a->rig->summary);
      return a;
    }

    static int size(const Node* x) { return x == nullptr ? 0 : x->size_; }

    static vector<Node*> nodes(Node* a) {
      vector<Node*> ret(size(a));
      nodes(a, ret, 0, size(a));
      return ret;
    }

    static void nodes(Node* a, vector<Node*> &ns, int L, int R) {
      if (a == nullptr) return;
      nodes(a->lef, ns, L, L + size(a->lef));
      ns[L + size(a->lef)] = a;
      nodes(a->rig, ns, R - size(a->rig), R);
    }

    static Node* merge(Node* a, Node* b) {
      if (b == nullptr) return a;
      if (a == nullptr) return b;
      if (a->priority > b->priority) {
        a->rig = merge(a->rig, b);
        return update(a);
      }
      else {
        b->lef = merge(a, b->lef);
        return update(b);
      }
    }

    static pair<Node*, Node*> split(Node* a, int k) {
      if (a == nullptr) return make_pair(nullptr, nullptr);
      if (k <= size(a->lef)) {
        auto s = split(a->lef, k);
        a->lef = s.second;
        s.second = update(a);
        return s;
      }
      else {
        auto s = split(a->rig, k - size(a->lef) - 1);
        a->rig = s.first;
        s.first = update(a);
        return s;
      }
    }
  };

  using node = Node;
  using np = node*;

  static np merge_technically(np a, np b) {
    if (node::size(a) > node::size(b)) swap(a, b);
    // |a|<=|b|

    for (np cur : node::nodes(a)) {
      cur->lef = cur->rig = nullptr;
      b = insert_b(b, cur);
    }
    return b;
  }

  static pair<np, np> split_less(np a, Val v) {
    if (a == nullptr) return make_pair(nullptr, nullptr);
    if (a->v < v) {
      auto s = split_less(a->rig, v);
      a->rig = s.first;
      s.first = node::update(a);
      return s;
    }
    else {
      auto s = split_less(a->lef, v);
      a->lef = s.second;
      s.second = node::update(a);
      return s;
    }
  }

  static pair<np, np> split_leq(np a, Val v) {
    if (a == nullptr) return make_pair(nullptr, nullptr);
    if (a->v <= v) {
      auto s = split_leq(a->rig, v);
      a->rig = s.first;
      s.first = node::update(a);
      return s;
    }
    else {
      auto s = split_leq(a->lef, v);
      a->lef = s.second;
      s.second = node::update(a);
      return s;
    }
  }

  static np insert_k(np a, int k, const Val v) {
    auto lr = node::split(a, k);
    return node::merge(node::merge(lr.first, new node(v)), lr.second);
  }

  static np insert_b(np a, np v) {
    auto lr = split_less(a, v->v);
    return node::merge(node::merge(lr.first, v), lr.second);
  }

  static np erase_k(np a, int k) {
    auto lr = node::split(a, k);
    auto mr = node::split(lr.second, 1);
    return node::merge(lr.first, mr.second);
  }

  static np erase_b(np a, Val v) {
    auto lr = split_less(a, v);
    auto mr = node::split(lr.second, 1);
    return node::merge(lr.first, mr.second);
  }

  static np get_k(np a, int k) {
    while (a != nullptr) {
      if (k < node::size(a->lef)) {
        a = a->lef;
      }
      else if (k == node::size(a->lef)) {
        break;
      }
      else {
        k = k - node::size(a->lef) - 1;
        a = a->rig;
      }
    }
    return a;
  }

  public:
  np root;

  Treap() : root(nullptr) {}
  Treap(np root) : root(root) {}
  Treap(Treap l, Treap r) : root(node::merge(l.root, r.root)) {}

  string to_string() const { string res; node::to_string(root, res, 0); return res; }

  int size() const { return node::size(root); }

  // [0, k), [k, N) に分割する
  pair<Treap, Treap> split_k(int k) {
    auto lr = node::split(root, k);
    return make_pair(Treap(lr.first), Treap(lr.second));
  }

  // v を k 番目に入れる
  void insert_k(const Val val, int k) {
    root = insert_k(root, k, val);
  }

  // k番目を消す
  void erase_k(int k) {
    root = erase_k(root, k);
  }

  // k番目の値を取得する
  Val operator[](int k) const {
    assert(size() > k);
    return get_k(root, k)->v;
  }

  // v を Key の昇順位置に入れる
  void insert_b(const Val val) {
    root = insert_b(root, new node(val));
  }

  // 最初に見つけた val を消す
  void erase_b(const Val val) {
    if (contains_b(val)) root = erase_b(root, val);
  }

  // q 未満の要素の数を返す(q以上の要素の最小のindex)
  int count_less_b(const Val q) const {
    auto a = root;
    int lsize = 0;
    while (a != nullptr) {
      if (a->v < q) {
        lsize += node::size(a->lef) + 1;
        a = a->rig;
      }
      else {
        a = a->lef;
      }
    }
    return lsize;
  }

  // q 以上の要素の数を返す(qを越える要素の最小のindex)
  int count_leq_b(const Val q) const {
    auto a = root;
    int lsize = 0;
    while (a != nullptr) {
      if (a->v <= q) {
        lsize += node::size(a->lef) + 1;
        a = a->rig;
      }
      else {
        a = a->lef;
      }
    }
    return lsize;
  }

  // q の数を返す
  int count_b(const Val q) const {
    return count_leq(q) - count_less(q);
  }

  // q を含むかどうか
  bool contains_b(const Val q) const {
    auto a = root;
    while (a != nullptr) {
      if (a->v == q) return true;
      else if (a->v < q) a = a->rig;
      else a = a->lef;
    }
    return false;
  }

  // v未満の値 と v以上の値 に分割
  pair<Treap, Treap> split_less_b(const Val v) {
    auto lr = split_less(root, v);
    return make_pair(Treap(lr.first), Treap(lr.second));
  }

  // v以下の値 と vより大きい値 に分割
  pair<Treap, Treap> split_leq_b(const Val v) {
    auto lr = split_leq(root, v);
    return make_pair(Treap(lr.first), Treap(lr.second));
  }
};
template<class Val> ostream& operator<<(ostream& os, const Treap<Val>& treap) { os << treap.to_string(); return os; }

ll solve() {
  rea(int, n, k);
  rea_vec(int, n, A);

  forr(a, A) a -= k;

  Treap<ll> treap;
  vector<ll> R(sz(A)+1);
  rep(ii, sz(A)) R[ii+1] = R[ii] + A[ii];

  out(R);
  forr(r, R) treap.insert_b(r);

  ll ans = 0;

  rep(i, n) {
    ll r = R[i];
    treap.erase_b(r);
    int c = treap.count_less_b(r);
    int d = (n-i)-c;
    ans += d;
    out(i, r, c, d);
  }
  return ans;
}

void Main() {
  cout << solve() << endl;
}

signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 12800