#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200 * 1000 + 10;
vector<int> vec[MAXN];
int h[MAXN], par[30][MAXN], n;
void dfs(int v, int hh) {
  h[v] = hh;
  for (int i = 0; i < (int)vec[v].size(); i++) dfs(vec[v][i], hh + 1);
}
int get_par(int u, int k) {
  for (int i = 0; i <= log2(n); i++)
    if (k & (1 << i)) u = par[i][u];
  return u;
}
int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  u = get_par(u, h[u] - h[v]);
  if (u == v) return u;
  for (int i = log2(n); i >= 0; i--)
    if (par[i][v] != par[i][u]) u = par[i][u], v = par[i][v];
  return par[0][u];
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int t;
    cin >> t;
    t--;
    vec[t].push_back(i);
    par[0][i] = t;
  }
  par[0][0] = -1;
  for (int j = 1; j <= log2(n); j++)
    for (int i = 0; i < n; i++) par[j][i] = -1;
  dfs(0, 0);
  for (int j = 1; j <= log2(n); j++)
    for (int i = 0; i < n; i++)
      if (par[j - 1][i] != -1) par[j][i] = par[j - 1][par[j - 1][i]];
  int u = 0, v = 0, dis = 0;
  for (int i = 1; i < n; i++) {
    int k = lca(u, i), g = lca(v, i);
    int new_dis1 = h[u] + h[i] - 2 * h[k];
    int new_dis2 = h[v] + h[i] - 2 * h[g];
    if (new_dis1 > dis) dis = new_dis1, v = i;
    if (new_dis2 > dis) dis = new_dis2, u = i;
    cout << dis << " ";
  }
  cout << endl;
}
