#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
const int M = 1000000007;
const int N = 200001;
const int LN = 18;
vector<LL> g[N];
LL dp[LN][N], depth[N], color[N];
void dfs(LL s) {
  for (int node : g[s])
    if (color[node] == 0) {
      color[node] = 1;
      dp[0][node] = s;
      depth[node] = depth[s] + 1;
      dfs(node);
    }
}
LL lca(LL a, LL b) {
  if (depth[a] < depth[b]) swap(a, b);
  LL diff = depth[a] - depth[b];
  LL i;
  for (i = 0; i < LN; i++)
    if (diff & (1 << i)) a = dp[i][a];
  if (a != b) {
    for (i = LN - 1; i >= 0; i--)
      if (dp[i][a] != dp[i][b]) {
        a = dp[i][a];
        b = dp[i][b];
      }
    a = dp[0][a];
  }
  return a;
}
LL dis(LL a, LL b) {
  LL t = lca(a, b);
  return depth[a] + depth[b] - 2 * depth[t];
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout.setf(ios::fixed);
  LL n, i, j, m;
  cin >> n;
  LL a, b;
  for (i = 1; i < n; i++) {
    cin >> a;
    a--;
    b--;
    g[i].push_back(a);
    g[a].push_back(i);
  }
  color[n - 1] = 0;
  dp[0][0] = -1;
  color[0] = 1;
  dfs(0);
  for (i = 1; i < LN; i++)
    for (j = 0; j < n; j++) dp[i][j] = dp[i - 1][dp[i - 1][j]];
  LL v1 = 0, v2 = 0, dl = 0;
  for (i = 1; i < n; i++) {
    if (dis(v1, i) > dl) {
      dl = dis(v1, i);
      v2 = i;
    }
    if (dis(i, v2) > dl) {
      dl = dis(i, v2);
      v1 = i;
    }
    cout << dl << ' ';
  }
  cout << '\n';
}
