#include <bits/stdc++.h>
using namespace std;
int N;
long long D[202020];
long long E[202020];
vector<int> adj[202020];
int T[202020];
int H[202020];
long long ans;
void dfs(int v, int p) {
  int l = 0, h = 0;
  priority_queue<long long, vector<long long>, greater<long long> > pq;
  long long sum = 0;
  for (int i : adj[v]) {
    if (i == p) continue;
    dfs(i, v);
    if (H[i] >= H[v]) {
      h++;
      sum += D[i];
    } else {
      l++;
      sum += E[i];
    }
    if (H[i] == H[v]) pq.push(E[i] - D[i]);
  }
  D[v] = sum + max(h - 1, l) * (long long)T[v] + T[v];
  E[v] = sum + max(h, l - 1) * (long long)T[v] + T[v];
  if (v == 1) ans = sum + max(h, l) * (long long)T[v];
  while (pq.size()) {
    long long x = pq.top();
    pq.pop();
    sum += x;
    h--;
    l++;
    D[v] = min(D[v], sum + max(h - 1, l) * (long long)T[v] + T[v]);
    E[v] = min(E[v], sum + max(h, l - 1) * (long long)T[v] + T[v]);
    if (v == 1) ans = min(ans, sum + max(h, l) * (long long)T[v]);
  }
}
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 = 1; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
