## Mock CCC '18 Contest 5 J3/S1 - Median Triples

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type

Given a list of integers, compute the number of triples with such that the median of , , and is .

#### Input Specification

The first line of the input consists of two space-separated integers, and .

The next line contains space-separated integers, the values through representing the numbers of the list in order.

#### Output Specification

Output, on a single line, the number of valid triples.

#### Sample Input

4 1
1 1 2 2

#### Sample Output

2