You are given a permutation $p_1, p_2, \dots, p_n$. A permutation of length $n$ is a sequence such that each integer between $1$ and $n$ occurs exactly once in the sequence.

Find the number of pairs of indices $(l, r)$ ($1 \le l \le r \le n$) such that the value of the median of $p_l, p_{l+1}, \dots, p_r$ is exactly the given number $m$.

The median of a sequence is the value of the 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 \le l \le r \le n$) such that the value of the median of $p_l, p_{l+1}, \dots, p_r$ is exactly the given number $m$.
The first line contains integers $n$ and $m$ ($1 \le n \le 2\cdot10^5$, $1 \le m \le n$) — the length of the given sequence and the required value of the median.

The second line contains a permutation $p_1, p_2, \dots, p_n$ ($1 \le p_i \le n$). Each integer between $1$ and $n$ occurs in $p$ exactly once.
5 4
2 4 5 3 1
4
5 5
1 2 3 4 5
1
15 8
1 15 2 14 3 13 4 8 12 5 11 6 10 7 9
48
1 1
1
1
2 1
1 2
2
2 1
2 1
2
2 2
1 2
1
2 2
2 1
1
3 1
1 2 3
2
3 1
1 3 2
2
3 1
2 1 3
3
3 1
2 3 1
2
3 1
3 1 2
3
3 1
3 2 1
2
5 2
2 1 3 4 5
3
6 3
3 6 1 4 2 5
6
7 4
1 7 6 4 2 3 5
10
8 7
2 3 6 8 7 5 4 1
4
9 9
6 4 8 5 1 7 2 9 3
1
10 1
6 9 8 10 4 3 7 1 5 2
3
11 2
9 4 7 5 11 1 3 8 10 2 6
3
12 3
6 4 3 7 8 10 1 2 11 5 12 9
4
14 5
13 14 5 11 3 2 10 8 12 9 6 1 7 4
10
100 1
78 52 95 76 96 49 53 59 77 100 64 11 9 48 15 17 44 46 21 54 39 68 43 4 32 28 73 6 16 62 72 84 65 86 98 75 33 45 25 3 91 82 2 92 63 88 7 50 97 93 14 22 20 42 60 55 80 85 29 34 56 71 83 38 26 47 90 70 51 41 40 31 37 12 35 99 67 94 1 87 57 8 61 19 23 79 36 18 66 74 5 27 81 69 24 58 13 10 89 30
3
100 50
2 4 82 12 47 63 52 91 87 45 53 1 17 25 64 50 9 13 22 54 21 30 43 24 38 33 68 11 41 78 99 23 28 18 58 67 79 10 71 56 49 61 26 29 59 20 90 74 5 75 89 8 39 95 72 42 66 98 44 32 88 35 92 3 97 55 65 51 77 27 81 76 84 69 73 85 19 46 62 100 60 37 7 36 57 6 14 83 40 48 16 70 96 15 31 93 80 86 94 34
182
100 100
70 54 10 72 81 84 56 15 27 19 43 100 49 44 52 33 63 40 95 17 58 2 51 39 22 18 82 1 16 99 32 29 24 94 9 98 5 37 47 14 42 73 41 31 79 64 12 6 53 26 68 67 89 13 90 4 21 93 46 74 75 88 66 57 23 7 25 48 92 62 30 8 50 61 38 87 71 34 97 28 80 11 60 91 3 35 86 96 36 20 59 65 83 45 76 77 78 69 85 55
1
n,m=map(int,input().split())
nlist=list(map(int,input().split()))
def gorem(m):
    ans=0
    s=[0]*(2*n+1)
    s[n]=1
    summ=n
    add=0#recode the number lower that than in the current position
    for x in nlist:
        if x<m:
            summ-=1
            add-=s[summ]
        else:
            add+=s[summ]
            summ+=1
        ans+=add
        s[summ]+=1
    return ans
print(gorem(m)-gorem(m+1))