#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int n, a[M], h[M], in[M], out[M];
long long f[M], g[M], ans, res, s[M];
vector<int> e[M];
bool vis[M];
inline void ckmax(long long& x, long long y) { x < y ? (x = y) : 0; }
void dfs(int x, int pre) {
  vis[x] = 1;
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i];
    if (y != pre) dfs(y, x);
  }
  int K = 0;
  res = 0;
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i];
    if (y != pre) res += f[y], s[++K] = g[y] - f[y];
  }
  sort(s + 1, s + K + 1, greater<long long>());
  for (int i = 0; i <= K; i++) {
    res += s[i];
    if (pre) {
      ckmax(f[x], (long long)min(in[x] + i + 1, out[x] + K - i) * a[x] + res);
      ckmax(g[x], (long long)min(in[x] + i, out[x] + 1 + K - i) * a[x] + res);
    } else
      ckmax(f[x], (long long)min(in[x] + i, out[x] + K - i) * a[x] + res);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    ans += a[x] + a[y];
    if (h[x] == h[y])
      e[x].push_back(y), e[y].push_back(x);
    else {
      if (h[x] > h[y]) swap(x, y);
      in[x]++, out[y]++;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0), ans -= f[i];
  printf("%lld", ans);
  return 0;
}
