{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given an array $$$a$$$ of $$$n$$$ positive integers.\u003c/p\u003e\u003cp\u003eYou can use the following operation as many times as you like: select any integer $$$1 \\le k \\le n$$$ and do one of two things: \u003c/p\u003e\u003cul\u003e \u003cli\u003e decrement by one $$$k$$$ of the first elements of the array. \u003c/li\u003e\u003cli\u003e decrement by one $$$k$$$ of the last elements of the array. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor example, if $$$n\u003d5$$$ and $$$a\u003d[3,2,2,1,4]$$$, then you can apply one of the following operations to it (not all possible options are listed below): \u003c/p\u003e\u003cul\u003e \u003cli\u003e decrement from the first two elements of the array. After this operation $$$a\u003d[2, 1, 2, 1, 4]$$$; \u003c/li\u003e\u003cli\u003e decrement from the last three elements of the array. After this operation $$$a\u003d[3, 2, 1, 0, 3]$$$; \u003c/li\u003e\u003cli\u003e decrement from the first five elements of the array. After this operation $$$a\u003d[2, 1, 1, 0, 3]$$$; \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eDetermine if it is possible to make all the elements of the array equal to zero by applying a certain number of operations.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one positive integer $$$t$$$ ($$$1 \\le t \\le 30000$$$)\u0026nbsp;— the number of test cases. Then $$$t$$$ test cases follow.\u003c/p\u003e\u003cp\u003eEach test case begins with a line containing one integer $$$n$$$ ($$$1 \\le n \\le 30000$$$)\u0026nbsp;— the number of elements in the array.\u003c/p\u003e\u003cp\u003eThe second line of each test case contains $$$n$$$ integers $$$a_1 \\ldots a_n$$$ ($$$1 \\le a_i \\le 10^6$$$).\u003c/p\u003e\u003cp\u003eThe sum of $$$n$$$ over all test cases does not exceed $$$30000$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, output on a separate line: \u003c/p\u003e\u003cul\u003e \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e, if it is possible to make all elements of the array equal to zero by applying a certain number of operations. \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e, otherwise. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe letters in the words \u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e can be outputed in any case.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n3\n1 2 1\n5\n11 7 9 6 8\n5\n1 3 1 3 1\n4\n5 2 1 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nNO\nYES\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}