Problem G
Trains
Languages
en
is
You have arrived in Vilnius and want to visit various cities in Lithuania.
Cities in Lithuania are located on a straight line and
numbered from
Each city has a train station with a single train route that
operates from that station. You can only get on a train at the
start of its route, though you can get off at any of its stops.
Trains starting their route at the
To be more precise, if you get on a train in the
Task
You are going to visit some cities, using trains to travel between them. As you plan your trip, you start to wonder how many different options you have for your journey that starts at Vilnius. Two journeys are different if they make stops at different sequences of cities.
Calculate this number and print the answer modulo
Input
The first line contains one integer
Then
Output
Output a single integer - the number of ways you can visit
some of the
Constraints
-
-
(for each ) -
(for each )
Subtasks
No. |
Points |
Additional constraints |
1 |
8 |
|
2 |
13 |
|
3 |
16 |
For all trains, |
4 |
34 |
For all trains, |
5 |
29 |
No additional constraints. |
Examples
There are
Sample Input 1 | Sample Output 1 |
---|---|
5 1 3 2 1 1 3 0 10 3 5 |
7 |