#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, siz[N], p[N], a[N];
long long sum[N];
vector<int> adj[N];
void dfs(int u) {
  if (adj[u].empty())
    siz[u] = 1;
  else
    siz[u] = 0;
  sum[u] = a[u];
  for (auto v : adj[u]) dfs(v), siz[u] += siz[v], sum[u] += sum[v];
}
bool check(long long t) {
  for (int i = 1; i <= n; i++)
    if (sum[i] / (long long)siz[i] >= t && t * siz[i] < sum[i]) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) scanf("%d", &p[i]), adj[p[i]].push_back(i);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dfs(1);
  long long r = 1e18;
  for (long long k = 60, t; ~k; k--) {
    t = r - (1LL << k);
    if (t >= 0 && check(t)) r = t;
  }
  printf("%lld\n", r);
  return 0;
}
