#include const int N = 100010; using ll = long long; int a[N], b[N]; std::vector e[N]; ll dp[N][2]; void dfs(int u, int fa){ dp[u][0] = a[u]; for (auto v : e[u]){ if (v == fa){ continue; } dfs(v, u); dp[u][0] += std::max(dp[v][0], dp[v][1]); dp[u][1] += std::max(dp[v][0], dp[v][1] + b[u] + b[v]); } } int main(){ int n; scanf("%d", &n); for (int i = 1; i <= n; ++ i){ scanf("%d", &a[i]); } for (int i = 1; i <= n; ++ i){ scanf("%d", &b[i]); } for (int i = 0, u, v; i < n - 1; ++ i){ scanf("%d%d", &u, &v); e[u].emplace_back(v); e[v].emplace_back(u); } dfs(1, 0); printf("%lld\n", std::max(dp[1][0], dp[1][1])); return 0; }