import sys def input(): return sys.stdin.buffer.readline()[:-1] n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) adj = [[] for _ in range(n)] for i in range(n-1): u, v = map(int, input().split()) adj[u-1].append(v-1) adj[v-1].append(u-1) dp = [[0 for _ in range(2)] for _ in range(n)] visited = [False for _ in range(n)] stack = [(0, -1)] while stack: i, p = stack[-1] if not visited[i]: visited[i] = True for j in adj[i]: if j != p: stack.append((j, i)) else: stack.pop() dp[i][0] = a[i] for j in adj[i]: if j != p: dp[i][0] += max(dp[j][0], dp[j][1]) dp[i][1] += max(dp[j][0], dp[j][1] + b[i] + b[j]) print(max(dp[0]))