#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define MAX 1024
using namespace std;

typedef pair<int,int> P;

int n,p[MAX],d[MAX];
vector<P> e[MAX];
bool leaf[MAX];
bool visited[MAX];

void init(){
  for(int i=0;i<MAX;i++){
    e[i].clear();
    leaf[i]=false;
  }
}

int dfs(int v){
  visited[v]=true;
  int res=0;
  for(int i=0;i<e[v].size();i++){
    P next=e[v][i];
    if(!visited[next.f] && !leaf[next.f])res=max(res,dfs(next.f)+next.s);
  }
  return res;
}

int main()
{
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    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++){
      p[i]--;
      e[i].push_back(mp(p[i],d[i]));
      e[p[i]].push_back(mp(i,d[i]));
    }

    for(int i=0;i<n;i++)if(e[i].size()==1)leaf[i]=true;

    int ans=0;
    for(int i=1;i<n;i++){
      if(leaf[i] || leaf[p[i]])ans+=d[i];
      else ans+=d[i]*3;
    }
    int tmp=0;
    for(int i=0;i<n;i++){
      if(leaf[i])continue;
      for(int i=0;i<n;i++)visited[i]=false;
      tmp=max(tmp,dfs(i));
    }
    cout<<ans-tmp<<endl;
  }
  return 0;
}