#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}


struct Centroid{
  vector<Int> sz,dead;
  vector< vector<Int> > G;
  Centroid(){}
  Centroid(Int n):sz(n,1),dead(n,0),G(n){}

  void add_edge(Int u,Int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  Int dfs(Int v,Int p){
    sz[v]=1;
    for(Int u:G[v])
      if(u!=p&&!dead[u]) sz[v]+=dfs(u,v);
    return sz[v];
  }

  void find(Int v,Int p,Int tmp,vector<Int> &cs) {
    Int ok=1;
    for (Int u:G[v]){
      if(u==p||dead[u]) continue;
      find(u,v,tmp,cs);
      ok&=(sz[u]<=tmp/2);
    }
    ok&=(tmp-sz[v]<=tmp/2);
    if(ok) cs.emplace_back(v);
  }

  vector<Int> build(Int r) {
    Int tmp=dfs(r,-1);
    vector<Int> cs;
    find(r,-1,tmp,cs);
    return cs;
  }

  void disable(Int v){dead[v]=1;}
  void  enable(Int v){dead[v]=0;}
  Int alive(Int v){return !dead[v];}
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  Centroid G(n);
  for(Int i=1;i<n;i++){
    Int u,v;
    cin>>u>>v;
    u--;v--;
    G.add_edge(u,v);
  }

  vector<Int> as(n),bs(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<n;i++) cin>>bs[i];

  using P = pair<Int, Int>;
  vector<vector<P>> H(n);
  MFP([&](auto dfs,Int v,Int p)->Int{
        Int res=as[v]-bs[v];
        for(Int u:G.G[v]){
          if(u==p) continue;
          Int tmp=dfs(u,v);
          //cout<<u+1<<" "<<v+1<<":"<<-tmp<<endl;
          //cout<<v+1<<" "<<u+1<<":"<<+tmp<<endl;
          H[u].emplace_back(v,-tmp);
          H[v].emplace_back(u,+tmp);
          res+=tmp;
        }
        return res;
      })(0,-1);

  vector<Int> dp(n,0);
  queue<Int> que;
  que.emplace(G.build(0)[0]);

  vector<Int> tmp(n);
  while(!que.empty()){
    Int r=que.front();que.pop();

    for(Int t=0;t<2;t++){
      Int res=0;
      for(auto ch:H[r]){
        Int c=ch.first;
        if(!G.alive(c)) continue;

        // calc cost
        MFP([&](auto dfs,Int v,Int p,Int d)->void{
              // cout<<r+1<<":"<<v+1<<" "<<d<<endl;
              chmin(dp[v],-d+res);
              for(auto e:H[v]){
                Int u=e.first,w=e.second;
                if(u==p) continue;
                if(!G.alive(u)) continue;
                dfs(u,v,d+w);
              }
            })(c,r,ch.second);

        // update cost
        MFP([&](auto dfs,Int v,Int p,Int d)->void{
              chmin(res,d);
              for(auto e:H[v]){
                Int u=e.first,w=e.second;
                if(u==p) continue;
                if(!G.alive(u)) continue;
                dfs(u,v,d+w);
              }
            })(c,r,ch.second);
      }
      chmin(dp[r],res);
      reverse(H[r].begin(),H[r].end());
    }

    G.disable(r);
    for(Int c:G.G[r])
      if(G.alive(c))
        que.emplace(G.build(c)[0]);
  }
  // for(Int x:dp) cout<<x<<endl;

  Int ans=0;
  for(Int x:dp) ans+=x;
  cout<<-ans<<endl;
  return 0;
}



Measured memory_bytes: 27392