// Aizu 1196: Bridge Removal
// 2017.9.24 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { char f; int len, to[802], d[802]; } T;
T tbl[802];
int n;
int p[802], d[802];

int calc(int k)
{
	int i, j, max, s;

	if (tbl[k].f) return 0;
	tbl[k].f = 1;
	for (max = 0, i = 0; i < tbl[k].len; i++) {
		if ((j = tbl[k].to[i]) >= 0 && tbl[j].f == 0) {
			s = tbl[k].d[i] + calc(j);
			if (s > max) max = s;
		}
	}
	return max;
}

int main()
{
	int i, j, a, b, t, bridge, sum, max;
	T *q;

	while (scanf("%d", &n) && n) {
		memset(tbl, 0, sizeof(tbl));
		for (i = 1; i < n; i++) scanf("%d", &t), p[i] = t-1;
		for (sum = 0, i = 1; i < n; i++) scanf("%d", &t), d[i] = t, sum += t;
		for (i = 1; i < n; i++) {
			a = i, b = p[i];
			q = tbl + a, q->to[q->len] = b, q->d[q->len++] = d[i];
			q = tbl + b, q->to[q->len] = a, q->d[q->len++] = d[i];
		}
		bridge = sum;
		for (i = 0; i < n; i++) if (tbl[i].len == 1) {
			q = tbl + tbl[i].to[0];
			for (j = 0; j < q->len; j++) 
				if (q->to[j] == i) { sum -= q->d[j], q->to[j] = -1; break; }
		}

		for (max = 0, i = 0; i < n; i++) {
			if (tbl[i].len == 1) continue;
			for (j = 0; j < n; j++) tbl[j].f = 0;
			a = calc(i);
			if (a > max) max = a;
		}
		printf("%d\n", 2*sum + bridge - max);
	}
	return 0;
}