Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use two arrays to save the cumulative multipliers at each time point and cumulative sums adjusted by the current multiplier.
The function getIndex(idx) ask to the current value modulo 10^9+7. Use modular inverse and both arrays to calculate this value.