Traffic Congestion
Time limit3sMemory limit256 MB
Pick the tree city that minimizes the largest number of fans traveling on any single road when all fans leave the arena city.
Problem
Canada is a large country, but many areas have no residents and most people live near the southern border. The Trans-Canada Highway, completed in 1962, runs 7,821 km from St. John's in the east to Victoria in the west and connects the people living in that narrow strip of land.
Canadians like hockey. After a game, thousands of fans get into their cars and drive home, and the roads jam. A wealthy entrepreneur wants to buy a hockey team and build a new arena. Choose where to build it so that the traffic congestion after a game is as small as possible.
The country consists of cities joined by roads. Every road is bidirectional, and exactly one route connects any pair of cities. A route between cities and is a sequence of distinct cities such that a road joins and for every . The arena is built in one city, called the arena city. After a game, every fan except those who already live in the arena city travels from the arena city to their home city. The congestion on a road is proportional to the number of fans that travel along it. Pick the arena city so that the number of fans on the most congested road is as small as possible.
Input
The first line contains the number of cities . Cities are numbered from to .
The second line contains integers , where is the number of hockey fans living in city .
Each of the next lines contains two integers and , meaning that a road joins city and city .
Output
Print the number of the arena city on one line. If several cities give the same minimum for the most congested road, print the smallest such city number.
Constraints
- The roads connect all cities, and exactly one route joins any pair of cities.
Hint
Removing the arena city splits the country into pieces. The road that leaves the arena city toward one piece carries exactly the fans who live in that piece.