#include<iostream> #include<cstdio> #include<set> #include<queue> #define maxn 100010 #define ll long long #define cn const node usingnamespacestd;
constint p = 998244353;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1) { if (n & 1) s = s * x % p; x = x * x % p; } return s; }
int n, m;
structEdge { int to, next; } e[maxn]; int c1, head[maxn]; inlinevoidadd_edge(int u, int v){ e[c1].to = v; e[c1].next = head[u]; head[u] = c1++; }
int sz[maxn]; ll dis[maxn]; voiddfs(int u, int fa){ sz[u] = 1; for (int i = head[u]; ~i; i = e[i].next) { int v = e[i].to; if (v == fa) continue; dfs(v, u); sz[u] += sz[v]; } }
ll ans; voidDfs(int u, int fa){ ans = (ans + dis[u]) % p; for (int i = head[u]; ~i; i = e[i].next) { int v = e[i].to; if (v == fa) continue; dis[v] = (1 - sz[v] * pow_mod(sz[u] - 1, p - 2) + dis[u]) % p; Dfs(v, u); } }
intmain(){ fill(head, head + maxn, -1); ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n; for (int i = 2; i <= n; ++i) { int x; cin >> x; add_edge(x, i); } dfs(1, 0); Dfs(1, 0); cout << (ans * pow_mod(n, p - 2) % p + p) % p << "\n"; return0; }