#include <bits/stdc++.h>
using namespace std;
int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || '9' < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f * x;
}
const int MAXN = 200000;
const long long INF = 1000000000000000ll;
struct Edge {
  int v, nxt;
} edge[2 * MAXN + 5];
int ecnt, head[MAXN + 5];
void Addedge(int u, int v) {
  edge[++ecnt] = (Edge){v, head[u]}, head[u] = ecnt;
  edge[++ecnt] = (Edge){u, head[v]}, head[v] = ecnt;
  return;
}
long long ans, f[MAXN + 5][2];
vector<long long> val[MAXN + 5];
int w[MAXN + 5], h[MAXN + 5], cnt;
long long tmp[MAXN + 5];
void DFS(int u, int fa) {
  long long sum = 0, in = 0, out = 0;
  f[u][0] = f[u][1] = INF;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == fa) continue;
    DFS(v, u);
    if (h[u] > h[v])
      in++, sum += f[v][1];
    else if (h[u] < h[v])
      out++, sum += f[v][0];
    else
      val[u].push_back(f[v][1] - f[v][0]), out++, sum += f[v][0];
  }
  sort(val[u].begin(), val[u].end());
  for (int i = -1; i < (int)val[u].size(); i++) {
    if (i != -1) sum += val[u][i];
    if (u == 1)
      ans = min(ans, sum + 1ll * max(in, out) * w[u]);
    else {
      f[u][0] = min(f[u][0], sum + 1ll * max(in + 1, out) * w[u]);
      f[u][1] = min(f[u][1], sum + 1ll * max(in, out + 1) * w[u]);
    }
    in++, out--;
  }
  return;
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i <= n; i++) h[i] = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    Addedge(u, v);
  }
  ans = INF;
  DFS(1, 0);
  printf("%lld\n", ans);
  return 0;
}
