#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
using namespace std;
const int MAXN = 200005;
const int MAXM = 50005;
const long double EPS = 1e-8;
const int MOD = 1e9 + 7;
template <typename T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
void debug_out() { cerr << endl; }
template <typename T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
long long a[MAXN];
long long tmpw[MAXN], tmpa[MAXN];
struct Edge {
  int to;
  int nxt;
} edge[MAXN];
int tot = 1, head[MAXN];
long long leaf[MAXN], son[MAXN], lf[MAXN];
long long w[MAXN];
int n;
inline void add_edge(int u, int v) {
  edge[++tot].to = v;
  edge[tot].nxt = head[u];
  head[u] = tot;
}
void dfs0(int u) {
  bool isleaf = true;
  w[u] = a[u];
  for (int i = head[u]; i; i = edge[i].nxt) {
    son[u]++;
    isleaf = false;
    int v = edge[i].to;
    dfs0(v);
    w[u] += w[v];
    leaf[u] += leaf[v];
  }
  if (isleaf) {
    lf[u] = 1;
    leaf[u]++;
  }
}
bool flag = true;
void dfs(int u, long long x) {
  if (!flag) return;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    long long dif = (long long)leaf[v] * x - tmpw[v];
    if (dif < 0) {
      flag = false;
      return;
    } else if (dif <= tmpa[u]) {
      tmpa[u] -= dif;
      tmpw[u] -= dif;
      tmpa[v] += dif;
      tmpw[v] += dif;
      dfs(v, x);
    } else {
      tmpa[v] += tmpa[u];
      tmpw[v] += tmpa[u];
      tmpw[u] -= tmpa[u];
      tmpa[u] = 0;
      dfs(v, x);
    }
  }
  if (!lf[u] && tmpa[u]) flag = false;
}
inline bool check(long long x) {
  for (int i = (1); i <= (n); i++) {
    tmpa[i] = a[i];
    tmpw[i] = w[i];
  }
  flag = true;
  dfs(1, x);
  return flag;
}
void solve() {
  cin >> n;
  for (int i = (2); i <= (n); i++) {
    int pi;
    cin >> pi;
    add_edge(pi, i);
  }
  for (int i = (1); i <= (n); i++) cin >> a[i];
  dfs0(1);
  long long l = 0, r = 2e14;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid)) {
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  if (r >= 0 && check(r))
    cout << r << endl;
  else
    cout << l << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
