N dumplings sit in a row, all starting with flavor 0. Eating dumpling iii adds AiA_iAi flavor to every uneaten dumpling jjj with ∣i−j∣≤Di|i-j| \le D_i∣i−j∣≤Di. Maximize the total flavor you consume.
Line 1: NNN. Line 2: splatter distances DiD_iDi. Line 3: splash values AiA_iAi.
Print the maximum total flavor.