In the corporate realm of Raymond's company, employees occasionally slack during work hours. Raymond's vigilant boss conducts surprise checks to ensure that his employees' tasks are on track. Raymond is tasked with ensuring all numbers in an array
Each surprise inspection by his boss focuses on a specific subarray of
Raymond has two quick-fix strategies to make the elements in the selected subarray
- Choose an index
. For every index in the array , increase by . - Choose an index
. For every index in the array , multiply by .
Help Raymond determine, for each of these sudden inspections, whether it is possible to make all numbers in the subarray
Any changes Raymond makes will revert at the end of each inspection, so the array
Constraints
For all subtasks:
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line contains two integers
The second line contains
The next
Output Specification
For each sudden inspection, print YES
if it is possible for all elements in the subarray to become the same after performing the strategies at most twice, and NO
otherwise.
Sample Input
6 5
-2 3 3 3 2 0
1 6
2 3
3 5
1 5
1 4
Sample Output
YES
YES
NO
YES
NO
Comments