#include <bits/stdc++.h>

using namespace std;

#define MAXN 200010

long long n,q;
long long niz[MAXN];
vector<long long> adj[MAXN];
long long dist[MAXN];
queue<long long> bfsq;

void bfs(long long node)
{
    for (long long i=0;i<MAXN;i++) dist[i]=-1;
    dist[node]=0;

    bfsq.push(node);

    while (!bfsq.empty())
    {
        long long nodee=bfsq.front();
        bfsq.pop();

        long long s=adj[nodee].size();

        for (long long i=0;i<s;i++)
        {
            long long sled=adj[nodee][i];

            if (dist[sled]==-1)
            {
                dist[sled]=dist[nodee]+1;
                bfsq.push(sled);
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin>>n;

    for (long long i=1;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;

        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for (long long i=1;i<=n;i++) cin>>niz[i];

    cin>>q;

    long long mini=0;
    long long cvor=1;

    bfs(1);

    for (long long i=1;i<=n;i++) mini+=dist[i]*niz[i];

    for (long long i=2;i<=n;i++)
    {
        long long sum=0;

        bfs(i);

        for (long long j=1;j<=n;j++) sum+=dist[j]*niz[j];

        if (sum<mini)
        {
            mini=sum;
            cvor=i;
        }
    }

    cout<<cvor<<endl;
}