15101510 SUSTech Online Judge
Problem 1510 --Trivial Graph Problem

## 1510: Trivial Graph Problem

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1503  Solved: 223
[Submit][Status][Web Board]

## Description

Given an array $$a_1,a_2,...,a_n$$ which means the degree of nodes.

Satori wants to know if there is an undirected graph/a simple undirected graph/a tree whose sequence of degrees = array a.

## Input

The first line contains an integer $$n(1\le n\le100000)$$, i.e. the number of nodes.
Then one line follows. It contains n integers $$a_i\le 10000000$$, which means the degree of node i is $$a_i$$.

## Output

The first line print "YES"(without quotes) if there is an undirected graph whose sequence of degrees = array a, and "NO"(without quotes) otherwise.
The second line print"YES"(without quotes) if there is a simple undirected graph whose sequence of degrees = array a, and "NO"(without quotes) otherwise.
The third line print"YES"(without quotes) if there is a tree whose sequence of degrees = array a, and "NO"(without quotes) otherwise.

## Sample Input

6
3 3 1 1 1 1

## Sample Output

YES
YES
YES

[Submit][Status]