#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
const long long INF = 1e18;
int n;
long long t[maxn], h[maxn], deg[maxn];
vector<int> adj[maxn];
bool vis[maxn];
long long dp[maxn][2];
long long ans = 0;
void dfs(int v, int p = -1) {
  vis[v] = true;
  long long base = 0;
  vector<long long> difs;
  for (int i : adj[v])
    if (i != p) {
      dfs(i, v);
      base += dp[i][0];
      difs.push_back(dp[i][1] - dp[i][0]);
      deg[v]--;
    }
  dp[v][0] = dp[v][1] = INF;
  sort(difs.begin(), difs.end());
  int plus0 = p == -1 ? 0 : 1;
  int plus1 = p == -1 ? 0 : -1;
  for (long long x : difs) {
    dp[v][0] = min(dp[v][0], base + t[v] * abs(deg[v] + plus0));
    dp[v][1] = min(dp[v][1], base + t[v] * abs(deg[v] + plus1));
    base += x;
    deg[v] += 2;
  }
  dp[v][0] = min(dp[v][0], base + t[v] * abs(deg[v] + plus0));
  dp[v][1] = min(dp[v][1], base + t[v] * abs(deg[v] + plus1));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (h[a] == h[b]) {
      adj[a].push_back(b);
      adj[b].push_back(a);
    } else if (h[a] > h[b]) {
      deg[a]--;
      deg[b]++;
    } else {
      deg[a]++;
      deg[b]--;
    }
    ans += t[a] + t[b];
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      dfs(i);
      ans += dp[i][0];
    }
  printf("%lld\n", ans / 2);
}
