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).
import java.util.*;
import java.io.*;
public class B{
	static int n;
	static int m;
	static int[] arr;
	static int size = (int)(4e5)+2;
	
	static int[] bit;
	
	static void add(int idx)
	{
		while(idx<size)
		{
			bit[idx]++;
			idx += (idx&-idx);
		}
	}
	
	static long sum(int idx)
	{
		long sum = 0;
		while(idx>0)
		{
			sum += bit[idx];
			idx -= (idx&-idx);
		}
		return sum;
	}
	
	static long get(int m)
	{
		long ans = 0;
		int[] pre = new int[n+1];
		for(int i=1;i<=n;i++)
		{
			pre[i] += pre[i-1];
			if(arr[i]>=m)pre[i]++;
			else pre[i]--;
		}
		bit = new int[size];
		add(n+1);
		for(int i=1;i<=n;i++)
		{
			ans += sum(pre[i]+n);
			add(pre[i]+n+1);
//			System.out.println(ans);
		}
		return ans;
	}
	
	public static void main(String[] args)
	{
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		n = fs.nextInt(); m = fs.nextInt();
		arr = new int[n+1];
		for(int i=1;i<=n;i++)arr[i] = fs.nextInt();
		out.println(get(m)-get(m+1));
		out.close();
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static int[] sort(int[] arr)
	{
		List<Integer> temp = new ArrayList();
		for(int i:arr)temp.add(i);
		Collections.sort(temp);
		int start = 0;
		for(int i:temp)arr[start++]=i;
		return arr;
	}
	public static String rev(String str)
	{
		char[] arr = str.toCharArray();
		char[] ret = new char[arr.length];
		int start = arr.length-1;
		for(char i:arr)ret[start--] = i;
		String ret1 = "";
		for(char ch:ret)ret1+=ch;
		return ret1;
//		return ret;
	}
}