#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
struct Res {
  long long a, b, c;
};
bool operator<(const Res& p, const Res& q) { return p.a - p.b < q.a - q.b; }
int n;
int cost[MAXN];
int h[MAXN];
vector<int> adj[MAXN];
Res res[MAXN];
Res sub[MAXN];
int nsub;
long long asum[MAXN + 1];
long long bsum[MAXN + 1];
void dfs(int at, int par) {
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par) continue;
    dfs(to, at);
  }
  nsub = 0;
  long long fixedcost = 0;
  int fixedacnt = 0, fixedbcnt = 0;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par) continue;
    if (h[to] > h[at]) {
      fixedcost += res[to].a;
      ++fixedbcnt;
    } else if (h[at] > h[to]) {
      fixedcost += res[to].b;
      ++fixedacnt;
    } else {
      sub[nsub++] = res[to];
    }
  }
  sort(sub, sub + nsub);
  reverse(sub, sub + nsub);
  asum[0] = 0;
  for (int i = (0); i < (nsub); ++i) asum[i + 1] = asum[i] + sub[i].b;
  bsum[0] = 0;
  for (int i = (0); i < (nsub); ++i) bsum[i + 1] = bsum[i] + sub[i].a;
  res[at].a = res[at].b = res[at].c = LLONG_MAX;
  int ai = -1, bi = -1, ci = -1;
  for (int i = (0); i <= (nsub); ++i) {
    {
      int acnt = 1 + fixedacnt + i, bcnt = fixedbcnt + nsub - i;
      long long cur = fixedcost + (long long)max(acnt, bcnt) * cost[at] +
                      asum[i] + bsum[nsub] - bsum[i];
      if (cur < res[at].a) res[at].a = cur, ai = i;
    }
    {
      int acnt = fixedacnt + i, bcnt = 1 + fixedbcnt + nsub - i;
      long long cur = fixedcost + (long long)max(acnt, bcnt) * cost[at] +
                      asum[i] + bsum[nsub] - bsum[i];
      if (cur < res[at].b) res[at].b = cur, bi = i;
    }
    {
      int acnt = fixedacnt + i, bcnt = fixedbcnt + nsub - i;
      long long cur = fixedcost + (long long)max(acnt, bcnt) * cost[at] +
                      asum[i] + bsum[nsub] - bsum[i];
      if (cur < res[at].c) res[at].c = cur, ci = i;
    }
  }
}
long long solve() {
  dfs(0, -1);
  return res[0].c;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &cost[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &h[i]);
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    adj[a].push_back(b), adj[b].push_back(a);
  }
  printf("%lld\n", solve());
}
int main() {
  run();
  return 0;
}
