n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) g = [[] for _ in range(n)] for _ in range(n - 1): u, v = map(int, input().split()) u -= 1 v -= 1 g[u].append(v) g[v].append(u) dp = [[0 for _ in range(2)] for _ in range(n)] src = 0 st = [~ src, src] par = [None for _ in range(n)] while len(st) > 0: cur = st.pop() if cur >= 0: for nxt in g[cur]: if nxt == par[cur]: continue par[nxt] = cur st.append(~ nxt) st.append(nxt) else: dp[~ cur][0] += a[~ cur] if not par[~ cur] is None: dp[par[~ cur]][0] += max(dp[~ cur]) dp[par[~ cur]][1] += max(dp[~ cur][0], dp[~ cur][1] + b[~ cur] + b[par[~ cur]]) print(max(dp[src]))