#include<bits/stdc++.h>
#define ll long long
#define MAXN 200007
using namespace std;
vector<vector<int>>T(MAXN);
ll a[MAXN];
ll cost1[MAXN]={};
ll prefix1[MAXN]={};
bool visited[MAXN]={};
void cost(int node)
{
    prefix1[node]=a[node];
    visited[node]=true;
    for(auto i:T[node])
    {
        if(!visited[i])
        {
            cost(i);
            prefix1[node]+=prefix1[i];
            cost1[node]+=cost1[i]+prefix1[i];
        }
    }
}
int mini=1;
void findmin(int node)
{
    for(auto i:T[node])
    {
        ll tempCR=cost1[node]-cost1[i]-prefix1[i];
        ll tempPR=prefix1[node]-prefix1[i];
        ll c1=cost1[i]+tempCR+tempPR;
        if(c1<cost1[node] || (c1==cost1[node]&&i<mini))
        {
            mini=i;
            prefix1[node]=tempPR;
            cost1[node]=tempCR;
            cost1[i]=c1;
            prefix1[i]+=tempPR;
            findmin(i);
        }
    }
}
void solve1(int n)
{
    cost(1);
    //for(int i=1;i<=n;i++) cout<<cost1[i]<<endl;
    findmin(1);
    cout<<mini<<endl;
}
/*vector<int>v;
void chaindfs(int node)
{
    v.push_back(node);
    visited[node]=true;
    for(auto i:T[node])
    {
        if(!visited[i])
        {
            chaindfs(i);
        }
    }
}
ll get(ll p)
{

}
ll update(int val, int pos, int n)
{
    int l=0,r=n-1;
    int mid;
    if(v.size()==1) return v[0];
    while(l<=r)
    {
        mid=(l+r)/2;
        if((mid==0 && get(v[mid+1])>get(v[mid]))||(mid==n-1 && get(v[mid-1])>get(v[mid])))break;
        if(mid>0 && get(a[mid-1])<get(a[mid]))r=mid-1;
        else l=mid+1;
    }
    if(get(mid)==get(max(0,mid-1)))return min(v[mid],v[max(0,mid-1)]);
    if(get(mid)==get(max(n-1,mid+1)))return min(v[mid],v[max(n-1,mid-1)]);
    return v[mid];
}
void solve2(int n, int q)
{
    for(int i=1;i<=n;i++) visited[i]=0;
    for(int i=1;i<=n;i++)
    {
        if(T[i].size()==1)
        {
            chaindfs(i);
        }
    }
    map<int,int>p;
    for(int i=0;i<n;i++)p[v[i]]=i;
    while(q--)
    {
        ll val, pos;
        cin>>val>>pos;
        cout<<update(val,pos,n)<<endl;
    }
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        T[u].push_back(v);
        T[v].push_back(u);
    }
    for(int i=1;i<=n;i++) cin>>a[i];
    int q;
    cin>>q;
    if(q==0) solve1(n);
}