#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool getmin(T *a, const T &b) {
  if (b < *a) {
    *a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool getmax(T *a, const T &b) {
  if (b > *a) {
    *a = b;
    return true;
  }
  return false;
}
template <class T>
inline void read(T *a) {
  char c;
  while (isspace(c = getchar())) {
  }
  bool flag = 0;
  if (c == '-')
    flag = 1, *a = 0;
  else
    *a = c - 48;
  while (isdigit(c = getchar())) *a = *a * 10 + c - 48;
  if (flag) *a = -*a;
}
const int mo = 1000000007;
template <class T>
T pow(T a, T b, int c = mo) {
  T res = 1;
  for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c)
    if (b & i) res = 1LL * res * a % c;
  return res;
}
const int N = 1000100;
int f[N], mx1[N], mx2[N], g[N];
int n;
int main() {
  cin >> n;
  for (int i = (2); i <= (n + 1); ++i) {
    int j;
    read(&j);
    f[i] = j;
    g[i] = 1;
    int u = i;
    while (u > 1) {
      int v = f[u];
      if (g[u] > mx1[v])
        mx2[v] = mx1[v], mx1[v] = g[u];
      else if (g[u] > mx2[v])
        mx2[v] = g[u];
      if (max(mx1[v], mx2[v] + 1) > g[v])
        g[v] = max(mx1[v], mx2[v] + 1);
      else
        break;
      u = v;
    }
    printf("%d ", mx1[1]);
  }
  cout << endl;
  return 0;
}
