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 c0 and ck is a sequence of distinct cities c0,…,ck such that a road joins ci−1 and ci for every i. 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.
The first line contains the number of cities N. Cities are numbered from 0 to N−1.
The second line contains N integers P0,…,PN−1, where Pi is the number of hockey fans living in city i.
Each of the next N−1 lines contains two integers S and D, meaning that a road joins city S and city D.
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.
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.