#include <bits/stdc++.h>
using namespace std;
int par[1000001];
pair<int, int> ch1[1000001];
pair<int, int> ch2[1000001];
int level[1000001];
int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }
void update(int v, pair<int, int> x) {
  if (ch1[v].second == x.second) {
    ch1[v] = x;
    return;
  }
  if (ch2[v].second == x.second) {
    ch2[v] = x;
    return;
  }
  if (x.first > ch1[v].first) {
    pair<int, int> p = ch1[v];
    ch1[v] = x;
    if (p.first > ch2[v].first) ch2[v] = p;
  } else if (x.first > ch2[v].first) {
    pair<int, int> p = ch2[v];
    ch2[v] = x;
    if (p.first > ch1[v].first) ch1[v] = p;
  }
}
int calc(int v) {
  return max(min(ch1[v].first, ch2[v].first) + 1,
             max(ch1[v].first, ch2[v].first));
}
int main() {
  int n, i;
  scanf("%d", &n);
  par[0] = -1;
  ch1[0] = pair<int, int>(0, -1);
  ch2[0] = pair<int, int>(0, -1);
  level[0] = 1;
  for (i = 1; i <= n; i++) {
    scanf("%d", &par[i]);
    par[i]--;
    ch1[i] = pair<int, int>(0, -1);
    ch2[i] = pair<int, int>(0, -1);
    level[i] = 1;
    int v = i;
    while (par[v] != -1) {
      update(par[v], pair<int, int>(level[v], v));
      if (calc(par[v]) > level[par[v]]) {
        level[par[v]] = calc(par[v]);
        v = par[v];
      } else
        break;
    }
    printf("%d\n", max(ch1[0].first, ch2[0].first));
  }
  return 0;
}
