#include <bits/stdc++.h>
using namespace std;
int n, fir[1000005], sec[1000005], firid[1000005], secid[1000005], fa[1000005];
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n + 1; i++) {
    scanf("%d", &fa[i]);
    for (int j = i; fa[j]; j = fa[j]) {
      if (max(fir[j], sec[j] + 1) > fir[fa[j]]) {
        if (j == firid[fa[j]])
          fir[fa[j]] = max(fir[j], sec[j] + 1);
        else if (j == secid[fa[j]]) {
          sec[fa[j]] = fir[fa[j]];
          fir[fa[j]] = max(fir[j], sec[j] + 1);
          swap(firid[fa[j]], secid[fa[j]]);
        } else {
          sec[fa[j]] = fir[fa[j]];
          fir[fa[j]] = max(fir[j], sec[j] + 1);
          secid[fa[j]] = firid[fa[j]];
          firid[fa[j]] = j;
        }
      } else if (max(fir[j], sec[j] + 1) > sec[fa[j]]) {
        if (j == firid[fa[j]])
          break;
        else if (j == secid[fa[j]])
          sec[fa[j]] = max(fir[j], sec[j] + 1);
        else {
          sec[fa[j]] = max(fir[j], sec[j] + 1);
          secid[fa[j]] = j;
        }
      } else
        break;
    }
    printf("%d ", fir[1]);
  }
}
