atcoder#ARC113F. [ARC113F] Social Distance

[ARC113F] Social Distance

Score : 10001000 points

Problem Statement

Given is an integer sequence of length N+1N+1: X0,X1,,XNX_0,X_1,\ldots,X_N, where 0=X0<X1<<XN0=X_0 < X_1 < \ldots < X_N holds.

Now, NN people numbered 11 through NN will appear on a number line. Person ii will appear at a real coordinate chosen uniformly at random from the interval [Xi1,Xi][X_{i-1},X_i].

Find the expected value of the smallest distance between two people, modulo 998244353998244353.

Definition of the expected value modulo $998244353$

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 PQ\frac{P}{Q}, we have Q0(mod998244353)Q \neq 0 \pmod{998244353}. Thus, there uniquely exists an integer RR such that $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$. Report this RR.

Constraints

  • 2N202 \leq N \leq 20
  • 0=X0<X1<<XN1060=X_0 < X_1 < \cdots < X_N \leq 10^6

Input

Input is given from Standard Input in the following format:

NN

X0X_0 X1X_1 \ldots XNX_N

Output

Print the expected value of the smallest distance between two people, modulo 998244353998244353.

2
0 1 3
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 11 and Person 22. The answer is 3/23/2.

5
0 3 4 8 9 14
324469854

The answer is 196249/172800196249/172800.

20
0 38927 83112 125409 165053 204085 246405 285073 325658 364254 406395 446145 485206 525532 563762 605769 644863 683453 722061 760345 798556
29493181