#arc113f. [arc113_f]Social Distance
[arc113_f]Social Distance
Problem Statement
Given is an integer sequence of length : , where holds.
Now, people numbered through will appear on a number line. Person will appear at a real coordinate chosen uniformly at random from the interval \[X_{i-1},X_i\].
Find the expected value of the smallest distance between two people, modulo .
Definition of the expected value modulo
We can prove that the expected value in question is always a rational number. We can also prove that, under the constraints of this problem, if we express the expected value as an irreducible fraction , we have . Thus, there uniquely exists an integer such that $R \\times Q \\equiv P \\pmod{998244353}, 0 \\leq R < 998244353$. Report this .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the expected value of the smallest distance between two people, modulo .
Sample Input 1
2
0 1 3
Sample Output 1
499122178
There are just two people, so the expected value of the smallest distance between two people is just the expected value of the distance between Person and Person . The answer is .
Sample Input 2
5
0 3 4 8 9 14
Sample Output 2
324469854
The answer is .
Sample Input 3
20
0 38927 83112 125409 165053 204085 246405 285073 325658 364254 406395 446145 485206 525532 563762 605769 644863 683453 722061 760345 798556
Sample Output 3
29493181