#include <bits/stdc++.h>   using namespace std;   long long i, j, k, n, v[200010], m, a, b, x, y, h, w, l, p, ans, numitor, aux,       mini, sum, poz;   string s1, s2, second;   char c;   map<long long, long long> mip;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> x;     for (long long i = 1; i <= n; i++) {       cin >> v[i];       if (v[i] < x)         v[i] = -1;       else if (v[i] > x)         v[i] = 1;       else {         v[i] = 0;         poz = i;       }     }     mip[0] = 1;     sum = 0;     for (long long i = 1; i <= n; i++) {       sum += v[i];       if (i >= poz) {         if (mip.find(sum) != mip.end()) ans += mip[sum];         if (mip.find(sum - 1) != mip.end()) ans += mip[sum - 1];       } else {         mip[sum] += 1;         v[i] = sum;       }     }     cout << ans;     return 0;   }   