#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
long long fact[maxn];
vector<long long> g[maxn];
long long a[maxn], b[maxn], c[maxn], d[maxn];
void dfs(int u) {
  if (g[u].size() == 0) {
    b[u] = c[u] = a[u];
    d[u] = 1;
    return;
  }
  long long sum = 0, maxx = 0, cnt = 0;
  for (auto v : g[u]) {
    dfs(v);
    sum += b[v];
    maxx = max(maxx, c[v]);
    cnt += d[v];
  }
  d[u] = cnt, b[u] = sum + a[u];
  c[u] = max(maxx, b[u] / d[u] + (b[u] % d[u] ? 1LL : 0LL));
}
void solve() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int temp;
    cin >> temp;
    g[temp].push_back(i);
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  dfs(1);
  cout << c[1] << endl;
}
int main() {
  int T;
  for (T = 1; T; T--) {
    solve();
  }
}
