#include <bits/stdc++.h>
using namespace std;
const int N = 200032;
int n;
int par[N][18];
int h[N];
int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  for (int i = 17; i >= 0; i--)
    if (h[u] - (1 << i) >= h[v]) u = par[u][i];
  for (int i = 17; i >= 0; i--)
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  if (u == v) return u;
  return par[u][0];
}
int dis(int u, int v) { return h[u] + h[v] - 2 * h[lca(u, v)]; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int u = 1, v = 1, d = 0;
  for (int i = 2; i <= n; i++) {
    cin >> par[i][0];
    h[i] = h[par[i][0]] + 1;
    for (int j = 1; j < 18; j++) par[i][j] = par[par[i][j - 1]][j - 1];
    int x = dis(i, u), y = dis(i, v);
    if (x > d && x > y) {
      d = x;
      v = i;
    } else if (y > d) {
      d = y;
      u = i;
    }
    cout << d << " ";
  }
  cout << endl;
  return 0;
}
