#include <bits/stdc++.h>
using namespace std;
const int MXN = (int)2e5 + 5;
int n;
long long t[MXN], h[MXN], ans;
vector<int> v[MXN];
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first - a.second < b.first - b.second;
}
pair<long long, long long> dfs(int x, int pa) {
  int inn = 0, out = 0;
  pair<long long, long long> res = {(long long)1e18, (long long)1e18};
  long long all = 0, sum = 0, ch = 0;
  vector<pair<long long, long long> > tmp;
  for (auto i : v[x]) {
    pair<long long, long long> ret;
    if (i != pa) {
      ret = dfs(i, x);
      if (h[i] > h[x]) {
        out++;
        all += ret.first;
      }
      if (h[i] < h[x]) {
        inn++;
        all += ret.second;
      }
      if (h[i] == h[x]) {
        tmp.push_back(ret);
        sum += ret.second;
      }
      ch++;
    }
  }
  sort(tmp.begin(), tmp.end(), cmp);
  tmp.insert(tmp.begin(), {0, 0});
  long long cur = 0;
  for (int i = 0; i < ((int)(tmp).size()); i++) {
    cur += tmp[i].first - tmp[i].second;
    if (h[x] >= h[pa] && x != pa) {
      res.first = min(
          res.first,
          cur + sum + all +
              (ch + 1 - min(out + i, inn + 1 + ((int)(tmp).size()) - i - 1)) *
                  t[x]);
    }
    if (h[x] <= h[pa] && x != pa) {
      res.second = min(
          res.second,
          cur + sum + all +
              (ch + 1 - min(out + i + 1, inn + ((int)(tmp).size()) - i - 1)) *
                  t[x]);
    }
    if (x == pa) {
      res.first = min(
          res.first,
          cur + sum + all +
              (ch - min(out + i, inn + ((int)(tmp).size()) - i - 1)) * t[x]);
    }
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &t[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &h[i]);
  for (int i = 1; i < n; i++) {
    int fr, to;
    scanf("%d%d", &fr, &to);
    v[fr].push_back(to);
    v[to].push_back(fr);
  }
  printf("%lld\n", dfs(1, 1).first);
}
