import sys input = sys.stdin.readline N=int(input()) A=[0]+list(map(int,input().split())) B=[0]+list(map(int,input().split())) E=[[] for i in range(N+1)] for i in range(N-1): x,y=map(int,input().split()) E[x].append(y) E[y].append(x) QUE=[1] Parent=[-1]*(N+1) Parent[1]=N+1 TOP_SORT=[] # トポロジカルソート while QUE: x=QUE.pop() TOP_SORT.append(x) for to in E[x]: if Parent[to]==-1: Parent[to]=x QUE.append(to) DP0=[-1<<100]*(N+1) DP1=[-1<<100]*(N+1) for x in TOP_SORT[::-1]: if x!=1 and len(E[x])==1: DP0[x]=A[x] DP1[x]=0 else: S=0 for to in E[x]: if to==Parent[x]: continue S+=max(DP0[to],DP1[to]) DP0[x]=S+A[x] S2=0 for to in E[x]: if to==Parent[x]: continue S2+=max(DP1[to]+B[x]+B[to],DP0[to]+B[x]+B[to]-A[to],DP0[to]) DP1[x]=S2 print(max(DP0[1],DP1[1]))