#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr& g, ll first, ll second) {
  g[first].push_back(second);
  g[second].push_back(first);
}
void add_edge(wgr& g, ll first, ll second, ll z) {
  g[first].emplace_back(second, z);
  g[second].emplace_back(first, z);
}
struct d_ {
  template <typename T>
  d_& operator,(const T& first) {
    cerr << ' ' << first;
    return *this;
  }
  template <typename T, typename U>
  d_& operator,(const pair<T, U>& first) {
    cerr << ' ' << first.first << ',' << first.second;
    return *this;
  }
  template <typename T>
  d_& operator,(const vector<T>& first) {
    for (auto first : first) cerr << ' ' << first;
    return *this;
  }
} d_t;
ll n;
gr g;
vll v;
tll dfs(ll u) {
  if (!g[u].size()) return {v[u], 0, 1};
  ll mxl = 0, res = 0, ls = 0;
  vtll ch;
  for (auto& v : g[u]) {
    auto t = dfs(v);
    ch.emplace_back(t);
    auto [vmx, vres, vl] = t;
    mxl = max(mxl, vmx);
  }
  for (auto [vmx, vres, vl] : ch) {
    res += vres;
    res += (mxl - vmx) * vl;
    ls += vl;
  }
  ll give = min(res, v[u]);
  res -= give;
  v[u] -= give;
  if (v[u]) {
    ll ad = (v[u] + ls - 1) / ls;
    ll full = v[u] % ls;
    if (full == 0) full = ls;
    mxl += ad;
    res += ls - full;
  }
  return {mxl, res, ls};
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin >> n;
  g = gr(n);
  for (ll i(0); i < n - 1; i++) {
    ll first;
    cin >> first;
    g[first - 1].push_back(i + 1);
  }
  v = vll(n);
  for (ll i(0); i < n; i++) cin >> v[i];
  cout << get<0>(dfs(0)) << endl;
  return 0;
}
