import sys from collections import deque N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) edge = [[] for i in range(N)] for _ in range(N-1): u,v = map(int,input().split()) edge[u-1].append(v-1) edge[v-1].append(u-1) deq = deque([0]) parent = [-1] * N res = [] while deq: v = deq.popleft() res.append(v) for nv in edge[v]: if nv!=parent[v]: parent[nv] = v deq.append(nv) res = res[::-1] exist_dp = [0] * N not_exist_dp = [0] * N for v in res: #not_exist_dp not_exist_dp[v] = a[v] for nv in edge[v]: if nv!=parent[v]: not_exist_dp[v] += max(exist_dp[nv],not_exist_dp[nv]) #exist_dp for nv in edge[v]: if nv!=parent[v]: exist_dp[v] += max(b[v]+b[nv]+exist_dp[nv],not_exist_dp[nv]) print(max(exist_dp[0],not_exist_dp[0]))