Phage War is a little flash game. In this game, we want infect all cells by the transmission and breed of phages.
Originally, there is a cell infected by phages and this cell can breed a new phage every second. You should know that only the new born phages can inject other cells.
There are n cells around this cell, numbered from 1 to n. If there are Di phages reaching the i-th cell, the cell would be infected, and the phages journey will cost Ti seconds. To simplify it, we assume these phages will stay in this new cell and they can’t infect other cells. And the new cell cannot breed new phages and infect other cells.
Can you tell me how much time it costs to infect all cells at least?