Sheepland is a country with cities. There are roads connecting pairs of cities with each other. Road directly connects cities and . Initially, it is possible to travel from any city to any other city using only these roads.
All roads in Sheepland are planned to be renovated. Under the renovation plan, each road will be in one of four states:
Two-way: citizens from both cities and may cross this road into the other city.
One-way from city to city : only citizens from city may cross this road into city .
One-way from city to city : only citizens from city may cross this road into city .
Closed: no citizens from cities or may cross this road into the other city.
Unfortunately, the renovation plan has gone missing!
To try to recover it, you ask the mayor of each city how many cities are reachable from their city under the renovation plan. The mayor of the -th city replies with . However, some
mayors may have provided incorrect values.
A city is considered reachable from a city u if there exists a sequence where and a crossable road exists from to for all . In particular, a city is reachable from itself.
Help Sheepland determine whether there exists a renovation plan that is consistent with the number of cities reachable from each city, as reported by all mayors!
输入格式
Your program must read from standard input.
The first line of input contains one integer .
The second line of input contains space-separated integers .
The following lines of input each contain two space-separated integers. The -th of these lines contains and .
输出格式
Your program must print to standard output.
Output YES if a renovation plan that is consistent with the number of cities reachable from each city, as reported by all mayors, exists and NO otherwise.