#P1442A. Extreme Subtraction
Extreme Subtraction
No submission language available for this problem.
Description
You are given an array of positive integers.
You can use the following operation as many times as you like: select any integer and do one of two things:
- decrement by one of the first elements of the array.
- decrement by one of the last elements of the array.
For example, if and , then you can apply one of the following operations to it (not all possible options are listed below):
- decrement from the first two elements of the array. After this operation ;
- decrement from the last three elements of the array. After this operation ;
- decrement from the first five elements of the array. After this operation ;
Determine if it is possible to make all the elements of the array equal to zero by applying a certain number of operations.
The first line contains one positive integer () — the number of test cases. Then test cases follow.
Each test case begins with a line containing one integer () — the number of elements in the array.
The second line of each test case contains integers ().
The sum of over all test cases does not exceed .
For each test case, output on a separate line:
- YES, if it is possible to make all elements of the array equal to zero by applying a certain number of operations.
- NO, otherwise.
The letters in the words YES and NO can be outputed in any case.
Input
The first line contains one positive integer () — the number of test cases. Then test cases follow.
Each test case begins with a line containing one integer () — the number of elements in the array.
The second line of each test case contains integers ().
The sum of over all test cases does not exceed .
Output
For each test case, output on a separate line:
- YES, if it is possible to make all elements of the array equal to zero by applying a certain number of operations.
- NO, otherwise.
The letters in the words YES and NO can be outputed in any case.