Codeforces Round 927 (Div. 3) |
---|
Finished |
The Chaya tribe believes that there are $$$n$$$ signs of the apocalypse. Over time, it has been found out that the $$$i$$$-th sign occurs every $$$a_i$$$ years (in years $$$a_i$$$, $$$2 \cdot a_i$$$, $$$3 \cdot a_i$$$, $$$\dots$$$).
According to the legends, for the apocalypse to happen, the signs must occur sequentially. That is, first they wait for the first sign to occur, then strictly after it, the second sign will occur, and so on. That is, if the $$$i$$$-th sign occurred in the year $$$x$$$, the tribe starts waiting for the occurrence of the $$$(i+1)$$$-th sign, starting from the year $$$x+1$$$.
In which year will the $$$n$$$-th sign occur and the apocalypse will happen?
The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then follow the descriptions of the test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of signs.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, a_3, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$) — the periodicities of the signs.
For each test case, output a single integer — the year in which all $$$n$$$ signs will occur.
463 2 4 5 9 1851 2 3 4 551 1 1 1 1650 30 711 200 503 1006
36 5 5 2012
In the first set of input data of the example:
Name |
---|