import sys sys.setrecursionlimit(100050) N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) dp = [[0, 0] for _ in range(N)] E = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 E[u].append(v) E[v].append(u) def dfs(x, p=-1): ret = 0 cnt = 0 for y in E[x]: if y == p: continue dfs(y, x) dp[x][0] += max(dp[y]) dp[x][1] += max(dp[y][1] + B[x] + B[y],dp[y][0]) dp[x][0] += A[x] dfs(0) print(max(dp[0]))