#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int f(int banka, int brojacKoraka, vector<vector<int>>susedi, vector<int>zlatnici, vector<bool>posecen)
{
	int novac = zlatnici[banka] * brojacKoraka;
	posecen[banka] = true;
	for (int x : susedi[banka]) {
		if (!posecen[x])
		{
			brojacKoraka++;
			novac += f(x, brojacKoraka, susedi, zlatnici, posecen);
			brojacKoraka--;
		}
	}
	return novac;
}
int main()
{
	int n; cin >> n;
	vector<vector<int>>susedi(n + 1);
	vector<int> zlatnici(n + 1);
	for (int i = 0; i < n-1; i++)
	{
		int a, b; cin >> a >> b;
		susedi[a].push_back(b);
		susedi[b].push_back(a);
	}
	for (int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		zlatnici[i] = x;
	}
	int q; cin >> q;
	int minimumKristala = INT_MAX, index = n;
	for (int i = 1; i <= n; i++)
	{
		vector<bool> posecen(n + 1);
		int x = f(i, 0, susedi, zlatnici, posecen);
		if (x < minimumKristala) {
			minimumKristala = x;
			index = i;
		}
	}
	cout << index;
}