#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, m;
struct pr {
  int fa, fir, sec, w;
} a[N];
inline int read() {
  int s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s;
}
bool update(int x, int y) {
  int ans;
  if (a[x].w < a[y].sec) return 0;
  if (a[x].w > a[y].fir) {
    a[y].sec = a[y].fir;
    a[y].fir = a[x].w;
  } else if (a[x].w > a[y].sec)
    a[y].sec = a[x].w;
  ans = max(a[y].sec + 1, a[y].fir);
  if (a[y].w == ans)
    return 0;
  else {
    a[y].w = ans;
    return 1;
  }
}
void work(int k) {
  int x = m + 1, y = k;
  m++;
  a[m].fa = k;
  a[m].w = 1;
  while (x != 1) {
    if (!update(x, y)) break;
    x = y, y = a[y].fa;
  }
  cout << a[1].fir << "\n";
}
int main() {
  int x;
  a[1].w = 1;
  m = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    x = read();
    work(x);
  }
}
