#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; int dp[100100]; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector R(n-1); rep(i,n-1){ cin>>R[i]; R[i]--; } dp[n-1]=0; for(int i=n-2;i>=0;i--) dp[i]=dp[R[i]]+1; cout<