#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define type(x) ((siz[x] & 1) ? 2 : (f[x] <= (siz[x] - f[x]) ? 1 : 3))
const int maxn = 1e5 + 50;
int n,x,last[maxn],siz[maxn],f[maxn],p[maxn];
struct Edge{
	int v,nxt;
}e[maxn];
int read(){
	int x = 0;
	char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + (c ^ 48),c = getchar();
	return x;
}
inline void insert(int u,int v){
	static int cnt = 0;
	e[++cnt] = {v,last[u]},last[u] = cnt;
}
bool cmp(int u,int v){
	static int t1,t2;
	t1 = type(u),t2 = type(v);
	if(t1 != t2) return t1 < t2;
	else return siz[u] - 2 * f[u] > siz[v] - 2 * f[v];
}
void dfs(int u){
	siz[u] = 1,f[u] = 1;
	for(int i = last[u]; i; i = e[i].nxt){
		int v = e[i].v;
		dfs(v);
		siz[u] += siz[v];
	}
	int cnt = 0;
	for(int i = last[u]; i; i = e[i].nxt) p[++cnt] = e[i].v;
	sort(p + 1,p + cnt + 1,cmp);
	int cur = 1;
	while(cur <= cnt && type(p[cur]) == 1) f[u] += f[p[cur]],cur ++;
	int t = 0;
	while(cur <= cnt && type(p[cur]) == 2){
		if(!t) f[u] += f[p[cur]];
		else f[u] += siz[p[cur]] - f[p[cur]];
		t ^= 1,cur ++;
	}
	while(cur <= cnt){
		if(!t) f[u] += f[p[cur]];
		else f[u] += siz[p[cur]] - f[p[cur]];
		cur ++;
	}
	// cout << u << ' ' << f[u] << ' ' << type(u) << endl;
}
int main(){
	n = read();
	for(int i = 2; i <= n; i ++){
		x = read();
		insert(x,i);
	}
	dfs(1);
	printf("%d\n",f[1]);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back

const int MOD = 998244353, N = 2e5 + 5;
int two[N];
int add(int x, int y)
{
    x += y;
    while (x >= MOD)
        x -= MOD;
    while (x < 0)
        x += MOD;
    return x;
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int solve()
{
    int n, res = 0, pre = 0;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    for (int i = 0; i < n; i++)
    {
        // self min max
        res = add(res, mul(arr[i], arr[i]));
        res = add(res, mul(pre, arr[i]));
        pre = mul(pre, 2);
        pre = add(pre, arr[i]);
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    two[0] = 1;
    for (int i = 1; i < N; i++)
        two[i] = mul(two[i - 1], 2);
    cout << solve() << "\n";
    return 0;
}