#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct edge{
  int to, cost;
};
vector<edge> G[800];

pair<int, int> maxdist(int v, int st){
  int i, j, infty = 2020002000;
  int d[v];
  queue<int> Q; Q.push(st);
  rep(i, v)d[i] = infty;
  d[st] = 0;
  pair<int, int> res = mp(st, 0);
  for(;!Q.empty();){
    int now = Q.front();
    Q.pop();
    rep(i, G[now].size()){
      if(G[G[now][i].to].size() == 1)continue;
      if(d[G[now][i].to] == infty && d[G[now][i].to] > d[now] + G[now][i].cost){
        d[G[now][i].to] = d[now] + G[now][i].cost;
        Q.push(G[now][i].to);
        if(res.second < d[G[now][i].to])res = mp(G[now][i].to, d[G[now][i].to]);
      }
    }
  }

  return res;
}

int solve(int v){
  int i, j, res = 0, st;
  rep(i, v){
    if(G[i].size() == 1)res += G[i][0].cost + G[i][0].cost;
    else st = i;
  }
  pair<int, int> l = maxdist(v, st);
  pair<int, int> r = maxdist(v, l.first);
  res += r.second;
  return res;
}

signed main(void){
  int i, j;
  for(int testcase = 0;;testcase++){
    int(n);
    if(n == 0)break;
    int p[n - 1], d, res = 0;
    rep(i, n - 1)sc(p[i]);
    rep(i, n - 1){
      sc(d);
      res += d + d + d;
      G[i + 1].pb((edge){p[i] - 1, d});
      G[p[i] - 1].pb((edge){i + 1, d});
    }
    pri(res - solve(n));
    rep(i, 800)G[i].clear();

  }
  return 0;
}

Measured memory_bytes: 1364