func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> G[200005];   bool V[200006] = {0};   int S[200006] = {0};   int n;   long long d = 0, mx = 0;   void dfs(int p) {     V[p] = 1;     d++;     int u = 0;     for (int i = 0; i < G[p].size(); i++) {       int cp = G[p][i];       if (!V[cp]) {         dfs(cp);         u++;       }     }     if (!u) mx = max(mx, d);     d--;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       S[i] = x;       if (x == -1) continue;       G[x].push_back(i);       G[i].push_back(x);     }     for (int i = 1; i <= n; i++) {       if (!V[i] && S[i] == -1) {         d = 0;         dfs(i);       }     }     cout << mx;     return 0;   }   