#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
int n, par[200001], dp[200001][20], depth[200001], t, a, b;
int pant(int first, int g) {
  for (int j = 0; j < 31; j++) {
    if (g & (1 << j)) {
      first = dp[first][j + 1];
      g -= (1 << j);
    }
  }
  return first;
}
int lca(int first, int g) {
  if (depth[first] > depth[g]) swap(first, g);
  g = pant(g, depth[g] - depth[first]);
  if (first == g) return first;
  for (int i = 20 - 1; i >= 0; i--) {
    if (dp[first][i] != -1 && dp[first][i] != dp[g][i]) {
      first = dp[first][i];
      g = dp[g][i];
    }
  }
  return dp[first][1];
}
int dist(int first, int g) {
  return depth[first] + depth[g] - 2 * depth[lca(first, g)];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  depth[1] = 1;
  for (int i = 2; i < n + 1; i++) {
    cin >> t;
    par[i] = t;
    dp[i][1] = t;
    depth[i] = depth[t] + 1;
    for (int j = 2; j < 20; j++) dp[i][j] = dp[dp[i][j - 1]][j - 1];
    if (i == 2) {
      cout << 1 << " ";
      a = 1, b = 2;
    } else {
      if (dist(a, i) > dist(a, b) && dist(a, i) >= dist(b, i)) {
        b = i;
      } else if (dist(b, i) > dist(a, b) && dist(b, i) > dist(a, i)) {
        a = i;
      }
      cout << dist(a, b) << " ";
    }
  }
  return 0;
}
