#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
const int INF = 2139062143;
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = 0;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  x = f ? x : -x;
}
template <typename T>
void write(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 2e5 + 7;
struct EDGE {
  long long to, nxt;
} edge[N << 1];
long long n, E, a[N], b[N], head[N], f[N][2];
vector<long long> vec[N];
inline void addedge(long long u, long long v) {
  edge[++E].to = v;
  edge[E].nxt = head[u];
  head[u] = E;
}
inline void dfs(long long u, long long fa) {
  long long in = 0, out = 0, sum = 0;
  for (long long i = head[u]; i; i = edge[i].nxt) {
    long long v = edge[i].to;
    if (v == fa) continue;
    dfs(v, u);
    if (b[v] < b[u]) in++, sum += f[v][0];
    if (b[v] > b[u]) out++, sum += f[v][1];
    if (b[v] == b[u]) in++, sum += f[v][0], vec[u].push_back(f[v][1] - f[v][0]);
  }
  sort(vec[u].begin(), vec[u].end());
  for (long long i = 0; i <= vec[u].size(); i++) {
    f[u][0] = min(f[u][0], sum + max(out + (u != 1), in) * a[u]);
    f[u][1] = min(f[u][1], sum + max(out, in + (u != 1)) * a[u]);
    in--;
    out++;
    if (i < vec[u].size()) sum += vec[u][i];
  }
}
signed main() {
  read(n);
  for (long long i = 1; i <= n; i++) read(a[i]);
  for (long long i = 1; i <= n; i++) read(b[i]);
  for (long long i = 1, u, v; i < n; i++) {
    read(u);
    read(v);
    addedge(u, v);
    addedge(v, u);
  }
  memset(f, 0x3f, sizeof(f));
  dfs(1, 0);
  printf("%lld\n", min(f[1][0], f[1][1]));
  return 0;
}
