#include using namespace std; using i64 = long long; using u64 = unsigned long long; template requires (!is_convertible_v) ostream &operator<<(ostream &s, T &&v) { for (auto &&x : v) s << x << ' '; return s; } template void dbg(T... x) { #ifdef LOCAL char e{}; ((cerr << e << x, e = ' '), ...); cerr << '\n'; #endif } #define debug(x...) dbg(#x, '=', x) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define ff first #define ss second bool chmin(auto &&a, auto b) { return (b < a) and (a = b, true); } bool chmax(auto &&a, auto b) { return (a < b) and (a = b, true); } constexpr i64 mod = 998244353; constexpr i64 inf = 1E10; vector operator*(const vector &a, const vector &b) { int n = a.size(); int m = b.size(); vector c(n + m - 1); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { (c[i + j] += a[i] * b[j]) %= mod; } } return c; } void solve() { int N; cin >> N; vector pa(N, -1); for (int i = 1; i < N; i++) { cin >> pa[i]; pa[i]--; } vector dp(N, vector{1, 0}); for (int i = N - 1; i >= 0; i--) { for (int j = 1; j < dp[i].size(); j++) { (dp[i][j] += dp[i][j - 1]) %= mod; } if (pa[i] != -1) { dp[pa[i]] = dp[pa[i]] * dp[i]; } } i64 ans = reduce(all(dp[0]), 0LL) % mod; cout << ans << '\n'; } int main() { cin.tie(0)->sync_with_stdio(false); cin.exceptions(cin.failbit); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }