#P11542. Reliable Report Sorting

    ID: 13631 Type: Default 1000ms 256MiB

Reliable Report Sorting

Reliable Report Sorting

At Penguin High School, the administrative office faces challenges in managing a large number of student reports. Each report indicates the number of students entering (a positive integer) or leaving (a negative integer) the school. Initially, the school has 00 students. The reports are considered reliable if and only if there exists an ordering of these reports such that the cumulative number of students never becomes negative at any point (i.e. the running total is always 0\ge 0). Your task is to determine whether the given set of reports is reliable.

Note: The reports are provided in an unordered fashion, and you are allowed to rearrange them arbitrarily to achieve the required condition.

inputFormat

The first line contains a single integer nn (1n105)(1 \leq n \leq 10^5), the number of reports. The second line contains nn space-separated integers, where each integer represents a report. A positive integer signifies that many students entered the school, whereas a negative integer signifies that many students left the school.

outputFormat

Output a single line: "Yes" if the reports are reliable, and "No" otherwise.

sample

3
1 2 -3
Yes