#include <bits/stdc++.h>
using namespace std;
int n, u, v, cur, level[200007], p[20][200007], a;
int lca(int a, int b) {
  for (int i = 19; i >= 0; i--) {
    if (level[p[i][a]] >= level[b]) a = p[i][a];
  }
  for (int i = 19; i >= 0; i--) {
    if (level[p[i][b]] >= level[a]) b = p[i][b];
  }
  for (int i = 19; i >= 0; i--) {
    if (p[i][a] != p[i][b]) {
      a = p[i][a];
      b = p[i][b];
    }
  }
  while (a != b) {
    a = p[0][a];
    b = p[0][b];
  }
  return a;
}
int cal(int a, int b) {
  int x = lca(a, b);
  return level[a] + level[b] - 2 * level[x];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  u = 1;
  v = 1;
  cur = 0;
  for (int i = 0; i <= 19; i++) {
    p[i][1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    cin >> a;
    p[0][i] = a;
    level[i] = level[a] + 1;
    for (int j = 1; j <= 19; j++) {
      p[j][i] = p[j - 1][p[j - 1][i]];
    }
    int v1 = cal(u, i);
    int v2 = cal(v, i);
    int ans = max(v1, max(v2, cur));
    if (ans == v1)
      v = i;
    else if (ans == v2)
      u = i;
    cur = max(cur, ans);
    cout << cur << " ";
  }
}
