You are given an integer sequence a_1, a_2, ..., a_n.

Find the number of pairs of indices (l, r) (1 ≤ l ≤ r ≤ n) such that the value of median of a_l, a_{l+1}, ..., a_r is exactly the given number m.

The median of a sequence is the value of an element which is in the middle of the sequence after sorting it in non-decreasing order. If the length of the sequence is even, the left of two middle elements is used.

For example, if a=[4, 2, 7, 5] then its median is 4 since after sorting the sequence, it will look like [2, 4, 5, 7] and the left of two middle elements is equal to 4. The median of [7, 1, 2, 9, 6] equals 6 since after sorting, the value 6 will be in the middle of the sequence.

Write a program to find the number of pairs of indices (l, r) (1 ≤ l ≤ r ≤ n) such that the value of median of a_l, a_{l+1}, ..., a_r is exactly the given number m.

Input

The first line contains integers n and m (1 ≤ n,m ≤ 2⋅10^5) — the length of the given sequence and the required value of the median.

The second line contains an integer sequence a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2⋅10^5).

Output

Print the required number.

Examples

Input

5 4
1 4 5 60 4


Output

8


Input

3 1
1 1 1


Output

6


Input

15 2
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3


Output

97

Note

In the first example, the suitable pairs of indices are: (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 5), (4, 5) and (5, 5).
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e16;
const long long int mod = 1e9 + 7;
const long long int MOD = 998244353;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
vector<char *> tokenizer(const char *args) {
  char *token = new char[111];
  strcpy(token, args);
  token = strtok(token, ", ");
  vector<char *> v({token});
  while ((token = strtok(NULL, ", "))) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void debugg(vector<char *> args) { cerr << "\b\b "; }
#pragma clang diagnostic pop
template <typename Head, typename... Tail>
void debugg(vector<char *> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back();
  debugg(args, T...);
}
template <typename T>
T power(T a, T b) {
  if (b == 0) return 1;
  if (b == 1)
    return a;
  else {
    T res = (power(a, b / 2));
    if (b % 2) {
      return (res * res * a);
    } else {
      return res * res;
    }
  }
}
template <typename T>
long long power(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
inline long long int ceil(long long int a, long long int b) {
  return a / b + (a % b == 0 ? 0 : 1);
}
void factorial(vector<long long int> &fact, long long int n) {
  fact.resize(n + 1, 1);
  fact[0] = 1;
  fact[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fact[i] = ((fact[i - 1] % mod) * (i % mod)) % mod;
  }
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
long long int mod_inv(long long int a) {
  return (power<long long int>(a, mod - 2, mod)) % mod;
}
long long int ncr(long long int n, long long int r,
                  vector<long long int> &fact) {
  if (r > n or n < 0 or r < 0) return 0LL;
  return (((fact[n] % mod) * (mod_inv(fact[n - r]) % mod)) % mod *
          (mod_inv(fact[r]) % mod)) %
         mod;
}
long long int NCR(long long int n, long long int r, vector<long long int> &fact,
                  vector<long long int> &inv) {
  if (r > n or n < 0 or r < 0) return 0LL;
  return (((fact[n] % mod) * (inv[n - r]))) % mod * (inv[r]) % mod;
}
void modI(vector<long long int> &inv, long long int n,
          vector<long long int> &fact) {
  inv.resize(n + 1, 1);
  inv[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 0; --i) {
    inv[i] = ((inv[i + 1]) % mod * ((i + 1) % mod)) % mod;
  }
}
class array_with_negative_indices {
  static const int MAX_N = 4e5 + 40;
  static const int ZERO = 2e5 + 10;
  long long int s[MAX_N];

 public:
  long long int &operator[](const int &i) {
    if (ZERO + i >= MAX_N or ZERO + i < 0) {
      cerr << "Out of Bounds , trying to access index " << i << "\n";
      return s[0];
    }
    return s[ZERO + i];
  }
};
long long int n, m;
array_with_negative_indices cnt;
long long int great(vector<long long int> &v, long long int d) {
  long long int prefix_sum = 0;
  long long int lesser_cnt = 0;
  long long int ans = 0;
  cnt[prefix_sum] = 1;
  for (int i = 0; i < n; ++i) {
    if (v[i] >= d) {
      lesser_cnt += cnt[prefix_sum];
      prefix_sum++;
    } else {
      prefix_sum--;
      lesser_cnt -= cnt[prefix_sum];
    }
    ans += lesser_cnt;
    cnt[prefix_sum]++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> m;
  vector<long long int> v(n - 1 + 1);
  for (auto i = 0; i <= n - 1; i++) {
    cin >> v[i];
  };
  long long int x = great(v, m);
  {};
  for (int i = -n; i <= n; ++i) {
    cnt[i] = 0;
  }
  x -= great(v, m + 1);
  cout << ((x)) << "\n";
  ;
  return 0;
}
