시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB113342.857%

문제

You are given $n$ distinct points on a circle of length $L$.

You need to find the number of triangles with vertices in these points that contain the center of the circle inside, or on their border. 

입력

The first line of input contains two integers $n$ and $L$ ($3 \leq n \leq 300\,000$, $n \leq L \leq 10^9$).

Let's choose any point on the circle and call it $S$. Then any point $A$ on the circle can be encoded as $x$, $0 \le x < L$: clockwise distance from $S$ to $A$. We will call this number a coordinate of $A$.

The second line contains $n$ distinct integers $x_1, x_2, \ldots, x_n$: coordinates of the given points on the circle ($0 \leq x_i < L$).

출력

Print one integer: the number of triangles with vertices in the given points, that contain the center of the circle inside or on their border. 

예제 입력 1

3 10
0 1 2

예제 출력 1

0

예제 입력 2

10 10
0 1 2 3 4 5 6 7 8 9

예제 출력 2

60