#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, a, b; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, 0, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p, ll &s0, ll &s1) {
        ll r0 = v[i].a, r1 = 0;

        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;

            ll t0, t1;
            dfs(o.i, i, t0, t1);
            r0 += max(t0, t1);
            r1 += max(t0, t1 + v[o.i].b + v[i].b);
        }
        s0 = r0; s1 = r1;
    }
    void solve() {
        for (int i = 0; i < n; i++) {
            cin >> v[i].a;
        }
        for (int i = 0; i < n; i++) {
            cin >> v[i].b;
        }
        for (int i = 0; i < n - 1; i++) {
            int a, b;
            cin >> a >> b;
            a--; b--;

            add_edge(a, b);
            add_edge(b, a);
        }
        ll s0, s1;
        dfs(0, -1, s0, s1);
        cout << max(s0, s1) << endl;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};


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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);
    g.solve();

    return 0;
}