~/algor $ cat problems/ikki-korsatkich-uchliklar-soni
Triples with sum less than x
Medium
1000 ms
128 MB
47%
An array $a$ of $n$ integers and an integer $x$ are given. How many triples $i \lt j \lt k$ satisfy $a_{i} + a_{j} + a_{k} \lt x$?
Input
The first line contains two integers: $n$ and $x$.
The second line contains $n$ integers $a_{i}$.
Output
One integer — the number of triples.
Note
$3 \le n \le 1000$
$-10^{9} \le a_{i} \le 10^{9}$
$-3 \cdot 10^{9} \le x \le 3 \cdot 10^{9}$
Examples
Input #1
4 2 -2 0 1 3
Output #1
2
Input #2
3 0 1 1 1
Output #2
0