#include <bits/stdc++.h>
using namespace std;
const long long SZ = 26, MAXN = 2e5 + 20, MAXM = 6e6 + 20, inf = 1e9 + 100,
                L = 32;
const long long mod = 1e9 + 7;
const long double eps = 1e-15;
mt19937 rnd;
long long victims[MAXN];
long long vacant[MAXN];
long long leaves[MAXN];
long long arr[MAXN];
vector<vector<int> > g;
inline long long div_up(long long a, long long b) { return (a + b - 1) / b; }
void dfs(int v) {
  if (g[v].empty()) {
    ++leaves[v];
    victims[v] = arr[v];
    vacant[v] = 0;
    return;
  }
  long long mx = 0;
  for (int u : g[v]) {
    dfs(u);
    leaves[v] += leaves[u];
    mx = max(mx, victims[u]);
  }
  for (int u : g[v]) {
    vacant[v] += vacant[u] + (mx - victims[u]) * leaves[u];
  }
  if (arr[v] > vacant[v]) {
    arr[v] -= vacant[v];
    victims[v] = mx + div_up(arr[v], leaves[v]);
    vacant[v] = (leaves[v] - (arr[v] % leaves[v])) % leaves[v];
  } else {
    vacant[v] -= arr[v];
    victims[v] = mx;
  }
}
void solve() {
  int n;
  cin >> n;
  g.resize(n);
  int p;
  for (int i = 1; i < n; ++i) {
    cin >> p;
    g[--p].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  dfs(0);
  cout << victims[0] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int tests = 1;
  for (int i = 0; i < tests; ++i) solve();
}
