Guan has just recently bought a new HDB flat in Bishan, and currently lives there with his "best friend" Jiahai. One day, you decide to go visit them in their new HDB flat. This HDB flat has N floors, numbered 1 to N. The HDB flat also has L units each floor arranged from left to right in a row, and a corridor connecting all L units of that floor, numbered 1 to L. However, the staircases are designed very oddly in this new, experimental HDB block. On each floor i, Ti random staircases are placed in front of certain units that bring you up to the next floor.
As if this problem was not confusing enough, there are also weird coefficients you have to deal with. In particular, due to random obstructions and flower pots here and there, each floor has a "speed coefficient", labelled Si for each floor i. Travelling a certain distance on each floor i requires Si * (number of units travelled) units of time. It is guaranteed to be possible to reach Jiahai and Guan's unit.
Jiahai and Guan live on the rightmost unit of the top floor, aka unit L of floor N. You start off at unit 1 of floor 1. Help calculate the amount of time it will take to reach their unit.
4 7 2 2 3 6 9 1 5 3 1 3 5 0
4 8 5 2 3 6 7 2 2 4 9 3 3 4 5 2 0