#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0);
const double EPS = 1e-9;
const int oo = 2e9;
const long long MOD = 1e9 + 7;
const int N = 2e5 + 5;
vector<int> adj[N];
int leaves[N], arr[N];
long long sum[N];
void dfs(int u) {
  bool leave = 1;
  for (auto& v : adj[u]) {
    leave = 0;
    dfs(v);
    leaves[u] += leaves[v];
    sum[u] += sum[v];
  }
  sum[u] += arr[u];
  leaves[u] += leave;
}
int main() {
  int n;
  scanf("%d", &(n));
  for (int i = 0; i < n - 1; i++) {
    int p;
    scanf("%d", &(p));
    adj[p].push_back(i + 2);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(arr[i]));
  }
  dfs(1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, (sum[i] + leaves[i] - 1) / leaves[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
