#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
long long A[N];
int a[N];
long long Dp[N];
int Leafs[N];
vector<int> Adj[N];
void DFS1(int x = 1) {
  A[x] = a[x];
  Leafs[x] = (Adj[x].empty());
  for (int y : Adj[x]) {
    DFS1(y);
    A[x] += A[y];
    Leafs[x] += Leafs[y];
  }
}
long long GetFree1(int x) { return (long long)Dp[x] * Leafs[x] - A[x]; }
long long GetFree2(int x, long long Max) {
  return (long long)(Max - Dp[x]) * Leafs[x];
}
void Solve(int x = 1) {
  if (Adj[x].empty()) return void(Dp[x] = a[x]);
  for (int y : Adj[x]) Solve(y);
  long long Current = a[x];
  for (int y : Adj[x]) {
    Current -= GetFree1(y);
    Current = max(Current, 0LL);
  }
  long long Max = 0;
  for (int y : Adj[x]) Max = max(Max, Dp[y]);
  for (int y : Adj[x]) {
    Current -= GetFree2(y, Max);
    Current = max(Current, 0LL);
  }
  Dp[x] = Max + (long long)(Current + Leafs[x] - 1) / Leafs[x];
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    Adj[x].push_back(i + 1);
  }
  for (int x = 1; x <= n; x++) scanf("%d", a + x);
  DFS1();
  Solve();
  cout << Dp[1] << endl;
}
