Traffic Congestion

No attempts yetTime limit3sMemory limit256 MB

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 c0c_0 and ckc_k is a sequence of distinct cities c0,,ckc_0, \dots, c_k such that a road joins ci1c_{i-1} and cic_i for every ii. 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 NN. Cities are numbered from 00 to N1N-1.

The second line contains NN integers P0,,PN1P_0, \dots, P_{N-1}, where PiP_i is the number of hockey fans living in city ii.

Each of the next N1N-1 lines contains two integers SS and DD, meaning that a road joins city SS and city DD.

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

  • 1N2000001 \le N \le 200\,000
  • 1Pi1 \le P_i
  • P0++PN12000000000P_0 + \dots + P_{N-1} \le 2\,000\,000\,000
  • The N1N-1 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.