#include <bits/stdc++.h>

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct N002 {
   long n;
   T e;
   std::function<T(T, T)> compose;
   std::vector<T> xs;
   N002(long n_, T e_, std::function<T(T, T)> f) : n(1LL << (64 - __builtin_clzll(n_))), e(e_), compose(f) {
      xs.resize(2 * n, e);
      for(long i = n - 1; i >= 1; --i) {
         long s = 2 * i, t = 2 * i + 1;
         xs[i] = compose(xs[s], xs[t]);
      }
   }
};
template<typename T>
void update(N002<T>& u, long i, T e) {
   long k = i + u.n;
   u.xs[k] = e;
   while( k != 1 ) {
      k /= 2;
      long s = 2 * k, t = 2 * k + 1;
      u.xs[k] = u.compose(u.xs[s], u.xs[t]);
   }
}
template<typename T>
T rangeCompose2(N002<T>& u, long a, long b, long x, long z, long i) {
   long y = (x + z) / 2;
   if( a <= x and z <= b ) return u.xs[i];
   if( b <= x or z <= a ) return u.e;
   T p = rangeCompose2(u, a, b, x, y, i * 2);
   T q = rangeCompose2(u, a, b, y, z, i * 2 + 1);
   if( i >= u.n ) return u.e;
   return u.compose(p, q);
}
template<typename T>
T rangeCompose(N002<T>& u, long a, long b) {
   return rangeCompose2(u, a, b, 0, u.n, 1);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, k; scan(n, k);
      LI xs(n);
      for(long &x : xs) scan(x);
      for(long &x : xs) x -= k;
      // for(long x : xs) printf("%ld ", x);
      // putchar('\n');
      LI ys(n+1);
      ys[0] = 0;
      for(long i = 0; i < (long)xs.size(); ++i) ys[i+1] = ys[i] + xs[i];
      // for(long y : ys) printf("%ld ", y);
      // putchar('\n');
      LI ts = ys;
      std::sort(ts.begin(), ts.end());
      ts.erase(std::unique(ts.begin(), ts.end()), ts.end());
      std::map<long, long> map;
      for(long i = 0; i < (long)ts.size(); ++i) map[ts[i]] = i;
      N002<long> rangeSum((long)ts.size(), 0,
                          [](long x, long y){ return x + y; });
      long res = 0;
      for(long i = (long)xs.size()-1; i >= 0; --i) {
         long index = map[ys[i+1]];
         update(rangeSum, index, rangeSum.xs[index+rangeSum.n] + 1);
         long index2 = map[ys[i]];
         res += rangeCompose(rangeSum, index2, (long)ts.size());
         dumpll(index, index2);
         dumpll(i, res);
      }
      printf("%ld\n", res);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 23552