#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<long long int,int> P; //cost,to

struct vec{
    vector<P> edge;
};

vector<vec> V;

long long int dfs(int i, int pre){
    if(V[i].edge.size()==1&&V[i].edge[0].second==pre) return 0;
    long long int maxiumum=0;
    int cost=0;
    for(auto& e:V[i].edge){
        if(e.second==pre){
            cost=e.first;
            continue;
        }
        maxiumum=max(maxiumum,dfs(e.second,i));
    }
    return cost+maxiumum;
}

int main(){
    int n;
    while(cin>>n,n){
        V.clear();
        for(int i=0;i<n;i++)V.push_back(vec());
        int P[1000];
        int D[1000];
        for(int i=1;i<n;i++) cin>>P[i];
        for(int i=1;i<n;i++) cin>>D[i];
        for(int i=1;i<n;i++){
            int p=P[i]-1;
            V[i].edge.emplace_back(D[i],p);
            V[p].edge.emplace_back(D[i],i);
        }
        long long int ans=0;
        for(int i=1;i<n;i++) ans+=3*D[i];
        for(int i=0;i<n;i++){
            if(V[i].edge.size()==1) ans-=2*V[i].edge[0].first;
        }
        long long int longest=0;
        for(int i=0;i<n;i++){
            if(V[i].edge.size()==1)continue;
            longest=max(longest,dfs(i,-1));
        }
        ans-=longest;
        cout<<ans<<endl;
    }
    return 0;
}