CF1671B.Consecutive Points Segment

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

Consecutive Points Segment

You are given nn points with integer coordinates on a coordinate axis OXOX. The coordinate of the ii-th point is xix_i. All points' coordinates are distinct and given in strictly increasing order.

For each point ii, you can do the following operation no more than once: take this point and move it by 11 to the left or to the right (i..e., you can change its coordinate xix_i to xi−1x_i - 1 or to xi+1x_i + 1). In other words, for each point, you choose (separately) its new coordinate. For the ii-th point, it can be either xi−1x_i - 1, xix_i or xi+1x_i + 1.

Your task is to determine if you can move some points as described above in such a way that the new set of points forms a consecutive segment of integers, i. e. for some integer ll the coordinates of points should be equal to l,l+1,…,l+n−1l, l + 1, \ldots, l + n - 1.

Note that the resulting points should have distinct coordinates.

You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤2⋅1041 \le t \le 2 \cdot 10^4) — the number of test cases. Then tt test cases follow.

The first line of the test case contains one integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of points in the set xx.

The second line of the test case contains nn integers x1<x2<…<xnx_1 \lt x_2 \lt \ldots \lt x_n (1≤xi≤1061 \le x_i \le 10^6), where xix_i is the coordinate of the ii-th point.

It is guaranteed that the points are given in strictly increasing order (this also means that all coordinates are distinct). It is also guaranteed that the sum of nn does not exceed 2⋅1052 \cdot 10^5 (umn≤2⋅105um n \le 2 \cdot 10^5).

Output

For each test case, print the answer — if the set of points from the test case can be moved to form a consecutive segment of integers, print YES, otherwise print NO.

Samples

5
2
1 4
3
1 2 3
4
1 2 3 7
1
1000000
3
2 5 6
YES
YES
NO
YES
YES

在线编程 IDE

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