#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long t, n, a[200005], c[200005], la[200005], ans = 0;
vector<int> p[200005];
void dfs(int u) {
  for (auto v : p[u]) {
    dfs(v);
    c[u] += c[v];
    la[u] += la[v];
  }
  c[u] += a[u];
  ans = max(ans, c[u] / la[u] + (c[u] % la[u] != 0));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    p[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    if (p[i].empty()) la[i] = 1;
  dfs(1);
  cout << ans;
}
