#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline void read(int &x) {
char ch; while(!isdigit(ch=getchar()));
for(x=ch-'0';isdigit(ch=getchar());x=x*10+ch-'0');
}
const int MAXN = 500005;
int n, x[MAXN], y[MAXN], fa[MAXN], fir[MAXN], to[MAXN], nxt[MAXN], cnt;
inline void link(int u, int v) { to[++cnt] = v; nxt[cnt] = fir[u]; fir[u] = cnt; }
int q[MAXN];
double ans[MAXN];
inline LL Cross(LL a, LL b, LL c, LL d) { return a*d - b*c; }
int find(int i, int r) {
int l = 2, mid, re = r+1;
while(l <= r) {
mid = (l + r) >> 1;
if(Cross(x[i]-x[q[mid-1]], y[i]-y[q[mid-1]], x[i]-x[q[mid]], y[i]-y[q[mid]]) <= 0) re = mid, r = mid-1;
else l = mid+1;
}
ans[i] = (double)(y[q[re-1]]-y[i]) / (double)(x[i]-x[q[re-1]]);
return re;
}
void dfs(int u, int now) {
x[u] = x[fa[u]] + 1;
int pos = now ? find(u, now) : 1, id = q[pos];
q[pos] = u;
for(int i = fir[u]; i; i = nxt[i])
dfs(to[i], pos);
q[pos] = id;
}
int main () {
freopen("lost.in", "r", stdin);
freopen("lost.out", "w", stdout);
read(n);
for(int i = 1; i <= n; ++i) read(y[i]);
for(int i = 2; i <= n; ++i) read(fa[i]), link(fa[i], i);
dfs(1, 0);
for(int i = 2; i <= n; ++i) printf("%.10f\n", ans[i]);
}