#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {}
const int MAXN = 2e5 + 5;
vector<int> g[MAXN];
long long h[MAXN], p[MAXN], c[MAXN];
bool v[MAXN];
void dfs(int i) {
  v[i] = 1;
  for (int j : g[i]) {
    if (v[j]) continue;
    dfs(j);
    p[i] += p[j];
    h[i] = max(h[i], h[j]);
    c[i] += c[j];
  }
  if (g[i].size() <= 1 && i != 0) {
    c[i]++;
  }
  h[i] = max(h[i], p[i] / c[i] + (p[i] % c[i] > 0));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (__typeof(n) i = (1); i < (n); i++) {
    int x;
    cin >> x;
    x--;
    g[x].push_back(i);
    g[i].push_back(x);
  }
  for (__typeof(n) i = (0); i < (n); i++) {
    cin >> p[i];
  }
  dfs(0);
  cout << h[0] << '\n';
}
