Given the consecutive years' sales data of a company as an array of integers: , with denoting the total sales during the year, your current task is to present the annual sales graph.
Your boss would be most impressed if the sales graph showed that the total sales never decreased for every pair of consecutive years. For this, you are allowed to modify at most one element of the data array for the property to be true. (Any more and the change will be too obvious.)
Given , determine if it is possible to do this task.
Complete the function canModify
which takes in the integer array and returns the string YES
or NO
denoting whether it is possible to do the task.
Input Format
The first line of input denotes denoting the number of scenarios. The following lines describe the scenarios.
The first line of each scenario contains a single integer denoting the length of array . The second line contains space-separated integers .
Constraints
Output Format
For each scenario, print a single line containing a single string: either YES
or NO
denoting whether it is possible to do the task.
Sample Input 0
2
8
5 7 7 11 15 12 22 24
9
20 19 18 16 14 15 14 13 11
Sample Output 0
YES
NO
Explanation 0
In the first scenario, , and the annual sales graph looks as follows:
The graph can be modified to meet the necessary condition by changing to .
Thus, the answer is YES
.
In the second scenario, , and the graph looks like:
Clearly, it's impossible to change one element so that the sales never decreases.