#include <bits/stdc++.h>
using namespace std;
const int N = 2e5, inf = 2e9;
int n;
long long a[N], sum[N], leaves[N], ans;
vector<int> g[N];
void DFS(int x) {
  sum[x] = a[x];
  int children = 0;
  for (auto u : g[x]) {
    DFS(u);
    ++children;
    sum[x] += sum[u];
    leaves[x] += leaves[u];
  }
  if (children == 0) leaves[x] = 1;
  ans = max(ans, (sum[x] + leaves[x] - 1) / leaves[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i < n; ++i) {
    scanf("%d", &x);
    g[x - 1].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
  }
  DFS(0);
  printf("%lld\n", ans);
}
