#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 1e6 + 7, M = 2e6 + 7, INF = INT_MAX / 10;
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
vector<int> par(N);
vector<int> ret(N);
vector<multiset<int>> chd(N);
int getval(int i) {
  auto it = chd[i].begin();
  int ans = -*it;
  it++;
  if (it != chd[i].end()) {
    ans = max(ans, -*it + (i != 1));
  }
  return ans;
}
void updp(int x, int i, int j) {
  if (x == -1) return;
  chd[x].erase(chd[x].find(-i));
  chd[x].insert(-j);
  int n = getval(x);
  if (n == ret[x]) return;
  updp(par[x], ret[x], n);
  ret[x] = n;
}
void upd(int i) {
  ret[i] = 1;
  chd[par[i]].insert(0);
  updp(par[i], 0, 1);
}
void solve() {
  int n;
  cin >> n;
  par[1] = -1;
  for (int i = 2; i <= n + 1; i++) {
    cin >> par[i];
    upd(i);
    int ans = getval(1);
    cout << ans << " ";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
