#include <bits/stdc++.h>
using namespace std;
int parent[1000005];
int Max[2][1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i <= n + 1; i++) {
    int u;
    cin >> u;
    parent[i] = u;
    u = i;
    while (u > 0) {
      int res = max(Max[0][u], Max[1][u] + 1);
      if (Max[0][parent[u]] < res) {
        Max[0][parent[u]] = res;
        if (Max[0][parent[u]] == Max[1][parent[u]] + 1) break;
      } else if (Max[1][parent[u]] < res) {
        Max[1][parent[u]] = res;
        if (Max[0][parent[u]] > Max[1][parent[u]]) break;
      } else
        break;
      u = parent[u];
    }
    cout << max(Max[0][1], Max[1][1]) << ' ';
  }
}
