#abc263e. [abc263_e]Sugoroku 3

[abc263_e]Sugoroku 3

Problem Statement

There are NN squares called Square 11 though Square NN. You start on Square 11.

Each of the squares from Square 11 through Square N1N-1 has a die on it. The die on Square ii is labeled with the integers from 00 through AiA_i, each occurring with equal probability. (Die rolls are independent of each other.)

Until you reach Square NN, you will repeat rolling a die on the square you are on. Here, if the die on Square xx rolls the integer yy, you go to Square x+yx+y.

Find the expected value, modulo 998244353998244353, of the number of times you roll a die.

Notes

It can be proved that the sought expected value is always a rational number. Additionally, if that value is represented fracPQ\\frac{P}{Q} using two coprime integers PP and QQ, there is a unique integer RR such that RtimesQequivPpmod998244353R \\times Q \\equiv P\\pmod{998244353} and 0leqRlt9982443530 \\leq R \\lt 998244353. Find this RR.

Constraints

  • 2leNle2times1052 \\le N \\le 2 \\times 10^5
  • 1leAileNi(1leileN1)1 \\le A_i \\le N-i(1 \\le i \\le N-1)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN A1A_1 A2A_2 dots\\dots AN1A_{N-1}

Output

Print the answer.


Sample Input 1

3
1 1

Sample Output 1

4

The sought expected value is 44, so 44 should be printed.

Here is one possible scenario until reaching Square NN:

  • Roll 11 on Square 11, and go to Square 22.
  • Roll 00 on Square 22, and stay there.
  • Roll 11 on Square 22, and go to Square 33.

This scenario occurs with probability frac18\\frac{1}{8}.


Sample Input 2

5
3 1 2 1

Sample Output 2

332748122