409808: GYM103785 C Dualites in Pain - The Beginning

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Dualites in Pain - The Beginningtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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!

Input

The 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.

Output

Print NO if it is not possible to watch all the lectures, otherwise print YES.

ExamplesInput
5
1 2 3 4 5
Output
YES
Input
5
1 2 3 4 12
Output
NO

加入题单

算法标签: