AT_abc431_f [ABC431F] Almost Sorted 2
Description
You are given an integer sequence $ A=(A_1,A_2,\ldots,A_N) $ of length $ N $ and a positive integer $ D $ .
Find the number, modulo $ 998244353 $ , of integer sequences $ B=(B_1, B_2, \ldots, B_N) $ that can be obtained by rearranging $ A $ and satisfy the following condition:
- $ B_{i+1}\geq B_i-D $ holds for all $ i\ (1\leq i\leq N-1) $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ D $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $
Output Format
Print the answer.
Explanation/Hint
### Sample Explanation 1
The integer sequences satisfying the condition are $ (1,2,2,5),(2,1,2,5),(2,2,1,5) $ , which are three sequences.
### Constraints
- $ 2\leq N\leq 2\times 10^5 $
- $ 1\leq D\leq 10^6 $
- $ 1\leq A_i\leq 10^6 $
- All input values are integers.