CF2062B.Clockwork

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Clockwork

You have a sequence of nn time clocks arranged in a line, where the initial time on the ii-th clock is aia_i. In each second, the following happens in order:

  • Each clock's time decreases by 11. If any clock's time reaches 00, you lose immediately.
  • You can choose to move to an adjacent clock or stay at the clock you are currently on.
  • You can reset the time of the clock you are on back to its initial value aia_i.

Note that the above events happen in order. If the time of a clock reaches 00 in a certain second, even if you can move to this clock and reset its time during that second, you will still lose.

You can start from any clock. Determine if it is possible to continue this process indefinitely without losing.

Input

The first line of input contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases.

For each test case, the first line contains a single integer nn (2n51052 \leq n \leq 5 \cdot 10^5) — the number of time clocks.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \leq a_i \leq 10^9) — the initial times set on the clocks.

It is guaranteed that the sum of nn over all test cases does not exceed 51055\cdot 10^5.

Output

For each test case, print "YES" (without quotes) if it is possible to continue this process indefinitely, or "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

Note

In the first test case, you can move back and forth between the two clocks, resetting them repeatedly.

In the third test case, assuming that you start from clock 11 and follow the strategy below:

Initially, a=[4,10,5]a=[4,10,5].

  1. aa becomes [3,9,4][3, 9, 4]. You move to clock 22 and reset its time, resulting in a=[3,10,4]a=[3, 10, 4].
  2. aa becomes [2,9,3][2, 9, 3]. You move to clock 33 and reset its time, resulting in a=[2,9,5]a=[2, 9, 5].
  3. aa becomes [1,8,4][1, 8, 4]. You move to clock 22 and reset its time, resulting in a=[1,10,4]a=[1, 10, 4].
  4. aa becomes [0,9,3][0, 9, 3]. You move to clock 11, but you lose because a1a_1 reaches 00.

It can be proven that no other strategy allows you to continue this process indefinitely.

Samples

5
2
4 10
2
2 2
3
4 10 5
3
5 3 5
5
12 13 25 17 30
YES
NO
NO
YES
YES

在线编程 IDE

建议全屏模式获得最佳体验