#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * (long long)a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int d[200005], n, p[200005][20];
int lca(int a, int b) {
  if (d[a] < d[b]) swap(a, b);
  int h = d[a] - d[b];
  for (int i = 0; i < 20; i++)
    if (h >> i & 1) a = p[a][i];
  if (a == b) return a;
  for (int i = 20 - 1; i >= 0; i--)
    if (p[a][i] != p[b][i]) a = p[a][i], b = p[b][i];
  return p[a][0];
}
int main() {
  int T = 100, j, k, i, ca = 0, m;
  scanf("%d", &n);
  int s = 0, t = 0, D = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d", &j), j--;
    d[i] = d[j] + 1;
    p[i][0] = j;
    for (int k = 1; k < 20; k++) {
      p[i][k] = p[p[i][k - 1]][k - 1];
    }
    int a = lca(i, s), first = d[i] + d[s] - 2 * d[a];
    int b = lca(i, t), second = d[i] + d[t] - 2 * d[b];
    if (first >= second && first > D) {
      D = first, t = i;
    } else if (second >= first && second > D) {
      D = second, s = i;
    }
    printf("%d ", D);
  }
  return 0;
}
