#JSUTFPC2025C. Incomplete Cauchy Sequence —— 不完全柯西序列
Incomplete Cauchy Sequence —— 不完全柯西序列
Statement
Timothy became fascinated with mathematical analysis when he was in second grade.
Since you will be dealing more with integers in algorithm competitions, you don't need a foundation in mathematical analysis to analyze the entire dense but rather the discrete , ensuring that the given data is definitely within the range of .
Let be a sequence (where ). For each , define the distance between adjacent terms as . If the sequence is (non-monotonically) decreasing [1], then is called an Incomplete Cauchy sequence. For example, the general formula for the sequence is , that is, is an Incomplete Cauchy sequence; an array of the form is also an Incomplete Cauchy sequence; whereas is not, because does not satisfy the above definition.
Given an array of length , determine whether this array can be a continuous subsequence of an Incomplete Cauchy sequence [2].
Input
The first line contains an integer representing the length of the array, where .
The second line contains integers separated by spaces, representing each element in the array , where .
Output
If the array is a possible continuous subsequence of an Incomplete Cauchy sequence, output Yes. Otherwise, output No. The output is not case-sensitive. For example, YES and yEs are both considered as Yes.
Samples
3
-1 -2 -3
Yes
5
1 100 50 75 75
Yes
5
1 100 300 300 300
No