output_description: Print the number of the non-empty contiguous subsequences with an arithmetic
  mean that is greater than or equal to K.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      a_1
      a_2
      :
      a_N
attempt: import bisect
  from itertools import accumulate
  # python template for atcoder1
  import sys
  sys.setrecursionlimit(10**9)
  input = sys.stdin.readline
  
  
  def brute():
      N, K = map(int, input().split())
      L = [int(input()) for _ in range(N)]
      ans = 0
      for i in range(N):
          for j in range(i, N):
              if sum(L[i:j+1])/(j+1-i) >= K:
                  ans += 1
  
      print(ans)
  
  
  def solve():
      N, K = map(int, input().split())
      L = [int(input()) for _ in range(N)]
  
      L_acc = [0]+list(accumulate(L))
      for i in range(N+1):
          L_acc[i] -= (i)*K
  
      L_sort = list(sorted(set(L_acc)))
      L_comp = [-1]*(N+1)
      for i in range(N+1):
          key = L_acc[i]
          ind = bisect.bisect_left(L_sort, key)
          L_comp[i] = ind
      # BIT
      bit = [0]*(N+1)
  
      def sum_bit(i):
          s = 0
          while i > 0:
              s += bit[i]
              i -= i & (-i)
          return s
  
      def add(i, x):
          while i <= N:
              bit[i] += x
              i += i & (-i)
  
      ans = 0
      for i, l in enumerate(L_comp):
          if l == 0:
              ans += N-i
              continue
          ans += sum_bit(l)
          add(l, 1)
      print(ans)
  
  
  solve()
  
  
      ans = 0
      for i, l in enumerate(L_comp):
          if l == 0:
              ans += N-i
              continue
          ans += sum_bit(l)
          add(l, 1)
      print(ans)
  
  
  solve()
  
problem_description: Statement
  
  You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an
  integer K.
  
  a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤
  l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than
  or equal to K?
samples: [{"input": "3 6\n    7\n    5\n    7", "output": "5\n    \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n  * {a_1} = {7}\n  * {a_1, a_2} = {7, 5}\n  * {a_1, a_2, a_3} = {7, 5, 7}\n  * {a_2} = {5}\n  * {a_2, a_3} = {5, 7}\n  * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n    1", "output": "0\n    \n\n* * *"}, {"input": "7 26\n    10\n    20\n    30\n    40\n    30\n    20\n    10", "output": "13"}]