#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int N = 100010;
vector<ll> A(N),B(N);
vector<vector<int>> G(N);
vector<vector<ll>> dp(N,vector<ll>(2,-1));

void dfs(int v,int p) {
    for (int e:G[v]) {
        if (p == e) continue;
        dfs(e,v);
    }

    // v消す
    ll res = A[v];
    for (int e:G[v]) {
        if (p == e) continue;
        res += max(dp[e][0],dp[e][1]);
    }
    dp[v][0] = res;

    // v消さない
    res = 0;
    for (int e:G[v]) {
        if (p == e) continue;
        res += max(dp[e][0],dp[e][1] + B[v] + B[e]);
    }
    dp[v][1] = res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N - 1) {
        int a,b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,-1);
    cout << max(dp[0][0],dp[0][1]) << '\n';
    return 0;
}