#include <bits/stdc++.h>
using namespace std;
const int Max = 1e6 + 10;
int p[Max];
int dp[Max][2], x[Max];
void UPD(int v) {
  if (p[v] == 0) return;
  int prvx = x[v];
  x[v] = max(x[dp[v][0]], x[dp[v][1]] + 1);
  if (dp[p[v]][0] != v) {
    if (x[dp[p[v]][0]] < x[v])
      swap(dp[p[v]][0], dp[p[v]][1]), dp[p[v]][0] = v;
    else if (x[dp[p[v]][1]] < x[v])
      dp[p[v]][1] = v;
  }
  if (prvx != x[v]) UPD(p[v]);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  dp[1][0] = 0;
  for (int i = 2; i <= n + 1; i++) {
    cin >> p[i];
    dp[i][0] = 0, dp[i][1] = 0;
    UPD(i);
    cout << x[dp[1][0]] << ' ';
  }
}
