#include <bits/stdc++.h>
int fav[1111111], par[1111111], dp[1111111], n;
int main() {
  scanf("%d", &n);
  int ans = 0;
  for (int i = 2, x; i <= n + 1; ++i) {
    scanf("%d", par + i);
    dp[i] = 1;
    for (x = i; par[x] != 1; x = par[x]) {
      int p = par[x], original = dp[p];
      if (fav[p] == x)
        dp[p] = ((dp[p]) > (dp[x]) ? (dp[p]) : (dp[x]));
      else if (dp[x] > dp[fav[p]])
        fav[p] = x, dp[p] = dp[x];
      else
        dp[p] = ((dp[p]) > (dp[x] + 1) ? (dp[p]) : (dp[x] + 1));
      if (original == dp[p]) break;
    }
    printf("%d ", ans = ((ans) > (dp[x]) ? (ans) : (dp[x])));
  }
}
