#include <bits/stdc++.h>
using namespace std;
int root;
int V;
int parent[22][202020];
int depth[202020];
int lca(int u, int v) {
  if (depth[u] > depth[v]) swap(u, v);
  for (int k = 0; k < 22; k++) {
    if ((depth[v] - depth[u]) >> k & 1) {
      v = parent[k][v];
    }
  }
  if (u == v) return u;
  for (int k = 22 - 1; k >= 0; k--) {
    if (parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}
int main() {
  cin.sync_with_stdio(false);
  cin >> V;
  root = 0;
  parent[root][0] = -1;
  depth[0] = 0;
  int dip = 0;
  int u = 0, v = 0;
  vector<int> res;
  for (long long i = (long long)(1); i < (long long)(V); i++) {
    int p;
    cin >> p;
    p--;
    parent[0][i] = p;
    depth[i] = depth[p] + 1;
    for (int k = 0; k + 1 < 22; k++) {
      if (parent[k][i] < 0)
        parent[k + 1][i] = -1;
      else
        parent[k + 1][i] = parent[k][parent[k][i]];
    }
    int ndip1 = depth[i] + depth[u] - depth[lca(i, u)] * 2;
    int ndip2 = depth[i] + depth[v] - depth[lca(i, v)] * 2;
    if (ndip1 > ndip2) {
      if (dip < ndip1) {
        dip = ndip1;
        v = i;
      }
    } else {
      if (dip < ndip2) {
        dip = ndip2;
        u = i;
      }
    }
    res.push_back(dip);
  }
  for (long long i = (long long)(0); i < (long long)(res.size()); i++)
    printf("%d%c", res[i], i == res.size() - 1 ? '\n' : ' ');
  return 0;
}
