CF1932B Chaya Calendar

题目描述

某部落相信启示有 $n$ 个迹象。随着时间的推移,人们发现第 $i$ 个迹象每隔 $a_i$ 年出现一次(在 $a_i$ 年、$2\cdot a_i$ 年、$3\cdot a_i$ 年等)。 根据传说,为了发生启示,这些迹象必须按顺序出现。也就是说,首先他们等待第一个迹象的出现,然后严格在其之后,第二个迹象将出现,依此类推。也就是说,如果第 $i$ 个迹象出现在第 $x$ 年,部落将从第 $(x+1)$ 年开始等待第 $(i+1)$ 个迹象的出现。值得注意的是,**等待后面的迹象发生时,前面的所有迹象都可以多次在出现**。 第 $n$ 个迹象将在哪一年出现,启示将会第一次发生?

输入格式

输入的第一行包含一个整数 $t$($1\le t\le1000$),表示测试数据的数量。然后是每组测试数据的描述。 每组测试数据的第一行包含一个整数 $n$($1\le n\le100$),表示迹象的数量。 每组测试数据的第二行包含 $n$ 个整数 $a_1,a_2,a_3, \dots,a_n$($1\le a_i\le10^6$),是对迹象的周期性的描述。

输出格式

对于每组测试数据,输出一个整数,表示所有 $n$ 个迹象将出现的年份。 ### 样例解释 在示例的第一组输入数据中: - 在第 $ 3 $ 年发现第一个迹象; - 在第 $ 4 $ 年发现第二个迹象; - 在第 $ 8 $ 年发现第三个迹象; - 在第 $ 10 $ 年发现第四个迹象; - 在第 $ 18 $ 年发现第五个迹象; - 在第 $ 36 $ 年发现第六个迹象; - 可以证明,这是第一次发生“启示”。

说明/提示

In the first set of input data of the example: - The tribe will wait for the first sign in the $ 3 $ -rd year; - the tribe will wait for the second sign in the $ 4 $ -th year (since year $ 2 $ have already passed); - the tribe will wait for the third sign in the $ 8 $ -th year (since the second sign has already occurred in the $ 4 $ -th year); - the tribe will wait for the fourth sign in the $ 10 $ -th year (since year $ 5 $ have already passed); - the tribe will wait for the fifth sign in the $ 18 $ -th year (since year $ 9 $ have already passed); - the tribe will wait for the sixth sign in the $ 36 $ -th year (since the fifth sign has already occurred in the $ 18 $ -th year).