#include <bits/stdc++.h>
using namespace ::std;
const int maxn = 1e6 + 500;
const int mod = 1e9 + 7;
const int inf = 1e9 + 500;
int max1[maxn];
int azki1[maxn];
int max2[maxn];
int azki2[maxn];
int par[maxn];
pair<int, int> vec[7];
int cn = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  max1[1] = 0;
  azki1[1] = -1;
  max2[1] = -inf;
  azki2[1] = -1;
  int n;
  cin >> n;
  int p, v;
  pair<int, int> last;
  for (int i = 2; i <= n + 1; i++) {
    cin >> par[i];
    max1[i] = 0;
    azki1[i] = -1;
    max2[i] = -inf;
    azki2[i] = -1;
    v = i;
    while (v != 1) {
      p = par[v];
      last = make_pair(max1[p], max2[p]);
      if (azki1[p] != v) {
        vec[cn] = (make_pair(max1[p], azki1[p]));
        cn++;
      }
      if (azki2[p] != v) {
        vec[cn] = (make_pair(max2[p], azki2[p]));
        cn++;
      }
      vec[cn] = (make_pair(max(max1[v], (int)1), v));
      cn++;
      vec[cn] = (make_pair(max2[v] + 1, v));
      cn++;
      sort(vec, vec + cn);
      cn--;
      max1[p] = vec[cn].first;
      azki1[p] = vec[cn].second;
      while (vec[cn].second == azki1[p]) {
        cn--;
      }
      max2[p] = vec[cn].first;
      azki2[p] = vec[cn].second;
      cn = 0;
      if (max2[p] < -500) {
        max2[p] = -inf;
      }
      if (max1[p] < -500) {
        max1[p] = -inf;
      }
      if (max1[p] == last.first && max2[p] == last.second) {
        break;
      }
      v = p;
    }
    cout << max1[1] << ' ';
  }
}
