#include <bits/stdc++.h>   using namespace std;   const int INT_INF = 1e9;   const long long LL_INF = 1e18;   const int MAXN = 200003;   int n, m;   int A[MAXN];   long long calc(int m) {     long long ret = 0;     map<int, int> dp;     int sum = 0;     dp[sum] = 1;     long long add = 0;     for (int i = 1; i <= n; i++) {       if (A[i] < m) {         sum--;         add -= dp[sum];       } else if (A[i] >= m) {         add += dp[sum];         sum++;       }       ret += add;       dp[sum]++;     }     return ret;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1, x; i <= n; i++) {       scanf( %d , &x);       A[i] = x;     }     long long ret1 = calc(m);     long long ret2 = calc(m + 1);     printf( %lld , ret1 - ret2);     return 0;   }   