409808: GYM103785 C Dualites in Pain - The Beginning
Description
My dualite fiends, and Mithil, have been crying all semester long about their tiresome courses and no time to study. So I now help them draft a schedule that they will never follow :)
There are $$$N$$$ courses that they have this semester, and for each course, they require $$$a_i$$$ lectures to binge.
Each of my fiends has a compulsive need to watch the lectures of that course first which has the most unwatched lectures. Also, the dumdums that they are, they cannot watch two consecutive lectures of the same course!
Given the array containing the lectures of each course - your task is to find out whether my fiends would be able to watch all those lectures or not!
InputThe first line of input consists of a single number $$$N$$$ $$$(2 \leq N \leq 100)$$$ - the number of courses. I know right! 100 courses!! They do make it sound like a 100 though ;)
The second line contains $$$N$$$ space separated integers $$$a_i$$$ $$$(1 \leq a_i \leq 1000)$$$ - the elements of array $$$a$$$ - representing the lectures of the $$$i$$$th course. Again, 1000 lectures! RR hai ye bas.
OutputPrint NO if it is not possible to watch all the lectures, otherwise print YES.
ExamplesInput5 1 2 3 4 5Output
YESInput
5 1 2 3 4 12Output
NO