407611: GYM102860 B Triangles and a Circle
Description
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.
InputThe 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$$$).
OutputPrint one integer: the number of triangles with vertices in the given points, that contain the center of the circle inside or on their border.
ExamplesInput3 10 0 1 2Output
0Input
10 10 0 1 2 3 4 5 6 7 8 9Output
60