Inherited disease

No attempts yetTime limit1sMemory limit16 MB

Problem

Jeongmin is a single-celled organism. The name JMPABU (JeongMin is Paramecium & Amoeba Based Unicellular organism) says as much: it looks like a paramecium crossed with an amoeba. I watched Jeongmin for a little over a year and found two properties.

  • When a generation DD Jeongmin has a child, that child belongs to generation D+1D+1. A generation DD Jeongmin leaves exactly D+1D+1 children in its life, then dies.
  • Jeongmin carries an unusual gene. Depending on the order in which a Jeongmin is born, that gene can be the one that causes an inherited disease.

I own a single generation 0 Jeongmin, and I numbered it 0. Its descendants get numbers too. Take the smallest-numbered Jeongmin whose children are not numbered yet, then give its children the smallest unused numbers in birth order. Repeating that produces the numbering in the picture below.

How Jeongmin are numbered

I keep running experiments on which birth order leads to the disease. The method is simple: follow the birth orders one step at a time and examine the Jeongmin you land on. For example, look at the 1st child born to the generation 0 Jeongmin, then the 2nd child born to that one, then the 1st child born to that one. Along that path the numbers you see are 1, 3 and 7, in that order. Once the generation count grows the numbers get far too large to follow by hand. I need your help.

Input

The first line contains the generation DD (1D1001 \le D \le 100) you want to examine.

The second line contains DD integers separated by spaces. The ii-th integer did_i (1dii1 \le d_i \le i) means you look at the did_i-th child born to the generation i1i-1 Jeongmin.

Output

Print DD lines. On line kk, print the number of the generation kk Jeongmin you see while following the input. The number can be very large, so print it modulo 1,000,000,007.