//
// main.cpp
// Practice
//
// Created by Neel Shah on 11/27/14.
// Copyright (c) 2014 Neel Shah. All rights reserved.
//
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include<stack>
#include<map>
#include<queue>
#include <math.h>
#include<set>
#include<stdint.h>
#include <utility>
#define MAXN 100005
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long int ll;
typedef pair<int, int> mp;
template<class T> void chmin(T &t, const T &f) { if (t > f) t = f; }
template<class T> void chmax(T &t, const T &f) { if (t < f) t = f; }
int t[MAXN], n, i;
vector<int> adj[MAXN];
map<int , map<int, double> > dp;
double mini = 1000000;
int ans;
double sol(int s, int p)
{
if(dp.count(p) && dp[p].count(s))
return dp[p][s];
double ret = t[s] + 0.0, tot = 0.0;
for(int i=0; i<adj[s].size(); ++i)
{
int to = adj[s][i];
if(to == p)
continue;
dp[s][to] = sol(to, s);
tot += dp[s][to];
}
if(p == 0)
tot /= adj[s].size();
else if(adj[s].size()-1 != 0)
tot /= adj[s].size()-1;
return ret += tot;
}
int main()
{
scanf("%d", &n);
for(i=1; i<=n; ++i)
scanf("%d", &t[i]);
for(i=1; i<n; ++i)
{
int x, y;
scanf("%d %d", &x, &y);
adj[x].push_back(y);
adj[y].push_back(x);
}
for(int i=1; i<=n; ++i)
{
double val = sol(i, 0);
if(val < mini)
{
mini = val;
ans = i;
}
}
printf("%d", ans);
return 0;
}
Ly8KLy8gIG1haW4uY3BwCi8vICBQcmFjdGljZQovLwovLyAgQ3JlYXRlZCBieSBOZWVsIFNoYWggb24gMTEvMjcvMTQuCi8vICBDb3B5cmlnaHQgKGMpIDIwMTQgTmVlbCBTaGFoLiBBbGwgcmlnaHRzIHJlc2VydmVkLgovLwoKI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPGF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yAwLjAsIHRvdCA9IDAuMDsKICAgIAogICAgZm9yKGludCBpPTA7IGk8YWRqW3NdLnNpemUoKTsgKytpKQogICAgewogICAgICAgIGludCB0byA9IGFkaltzXVtpXTsKICAgICAgICBpZih0byA9PSBwKQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICBkcFtzXVt0b10gPSBzb2wodG8sIHMpOwogICAgICAgIHRvdCArPSBkcFtzXVt0b107CiAgICB9CiAgICAKICAgIGlmKHAgPT0gMCkKICAgICAgICB0b3QgLz0gYWRqW3NdLnNpemUoKTsKICAgIGVsc2UgaWYoYWRqW3NdLnNpemUoKS0xICE9IDApCiAgICAgICAgdG90IC89IGFkaltzXS5zaXplKCktMTsKICAgIAogICAgcmV0dXJuIHJldCArPSB0b3Q7Cn0KCmludCBtYWluKCkKewogICAgc2NhbmYoIiVkIiwgJm4pOwogICAgZm9yKGk9MTsgaTw9bjsgKytpKQogICAgICAgIHNjYW5mKCIlZCIsICZ0W2ldKTsKICAgIGZvcihpPTE7IGk8bjsgKytpKQogICAgewogICAgICAgIGludCB4LCB5OwogICAgICAgIHNjYW5mKCIlZCAlZCIsICZ4LCAmeSk7CiAgICAgICAgYWRqW3hdLnB1c2hfYmFjayh5KTsKICAgICAgICBhZGpbeV0ucHVzaF9iYWNrKHgpOwogICAgfQogICAgCiAgICBmb3IoaW50IGk9MTsgaTw9bjsgKytpKQogICAgewogICAgICAgIGRvdWJsZSB2YWwgPSBzb2woaSwgMCk7CiAgICAgICAgaWYodmFsIDwgbWluaSkKICAgICAgICB7CiAgICAgICAgICAgIG1pbmkgPSB2YWw7CiAgICAgICAgICAgIGFucyA9IGk7CiAgICAgICAgfQogICAgfQogICAgCiAgICBwcmludGYoIiVkIiwgYW5zKTsKICAgIHJldHVybiAwOwp9