#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const long long mod = 998244353;
const long long INF = 1e15 + 7;
struct EDGE {
  int v, nxt;
};
int tot, n, m, cnt;
int head[maxn * 2];
EDGE edge[maxn * 4];
long long run[maxn * 2];
long long ppp[maxn * 2];
bool lef[maxn * 2];
void AddEdge(int u, int v) {
  tot++;
  edge[tot].v = v;
  edge[tot].nxt = head[u];
  head[u] = tot;
}
bool dfs(int u, int fa) {
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == fa) continue;
    if (!dfs(v, u)) return false;
    run[u] += run[v];
    if (run[u] > INF) run[u] = INF;
  }
  if (run[u] < ppp[u]) return false;
  run[u] -= ppp[u];
  return true;
}
bool check(long long x) {
  for (int i = 1; i <= n; i++) run[i] = 0;
  for (int i = 1; i <= n; i++)
    if (!lef[i]) run[i] = x;
  return dfs(1, 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int u, v;
    u = i;
    scanf("%d", &v);
    lef[v] = true;
    AddEdge(u, v);
    AddEdge(v, u);
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &ppp[i]);
  long long l = 0, r = INF;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (!check(mid))
      l = mid + 1;
    else
      r = mid;
  }
  printf("%lld\n", l);
  return 0;
}
