#include <bits/stdc++.h>
using namespace std;
long long solve();
long long mo = 1000000007;
vector<long long> a;
string s;
long long n;
vector<long long> adj[200001];
long long dp[200001][3];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long in(vector<long long> &a, long long n) {
  long long i = 0, x, sum = 0;
  for (i = 0; i < n; i++) {
    cin >> x;
    a.push_back({x});
    sum += x;
  }
  return sum;
}
long long out(vector<long long> a, long long l, long long r) {
  for (long long i = l; i <= r; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
void dfs(long long c) {
  if (adj[c].size() == 0) {
    dp[c][0] = a[c];
    dp[c][1] = 0;
    dp[c][2] = 1;
    return;
  }
  long long ma = 0, sum = 0, cnt = 0;
  for (auto u : adj[c]) {
    dfs(u);
    ma = max(dp[u][0], ma);
    sum += dp[u][1];
    cnt += dp[u][2];
  }
  for (auto u : adj[c]) {
    sum += (ma - dp[u][0]) * dp[u][2];
  }
  if (a[c] <= sum) {
    sum -= a[c];
    dp[c][0] = ma;
    dp[c][1] = sum;
    dp[c][2] = cnt;
    return;
  }
  a[c] -= sum;
  long long i = a[c] / cnt;
  if (a[c] % cnt != 0) i++;
  dp[c][0] = ma + i;
  dp[c][1] = i * cnt - a[c];
  dp[c][2] = cnt;
  return;
}
long long solve() {
  a.clear();
  s.clear();
  long long i = 0, j = 0, k = 0;
  long long flag = 0;
  long long x = 0, y = 0, z = 0;
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> x;
    adj[x].push_back(i);
  }
  a.push_back(0);
  in(a, n);
  dfs(1);
  cout << dp[1][0] << endl;
  return 0;
}
