#include <bits/stdc++.h>
using namespace std;
struct _ {
  _() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
  stringstream ss;
} _;
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
  o << "(" << t.first << ", " << t.second << ")";
  return o;
}
template <class T>
inline string tostring(T first) {
  _.ss.clear();
  _.ss.str("");
  _.ss << first;
  return _.ss.str();
}
template <class T>
inline T convert(const string &s) {
  char *p;
  if (is_integral<T>())
    return strtoll(s.c_str(), &p, 10);
  else
    return strtod(s.c_str(), &p);
}
template <class T>
void PV(T a, T b, int p = 0, int w = 0, string s = " ") {
  int c = 0;
  while (a != b) {
    cout << setw(w) << *a++;
    cout << ((a != b && (!p || ++c % p)) ? s : "\n");
  }
  cout.flush();
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
const long long linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 1000010;
int n;
int p[N];
int mx[N], cnt[N], dp[N];
int main() {
  cin >> n;
  n++;
  for (int i = 2; i <= n; i++) cin >> p[i];
  memset(mx, -1, sizeof(mx));
  ;
  memset(cnt, 0, sizeof(cnt));
  ;
  vector<int> res;
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    dp[i] = 1;
    int t = i;
    while (t > 0) {
      if (dp[t] == mx[p[t]]) {
        cnt[p[t]]++;
      } else if (dp[t] > mx[p[t]]) {
        mx[p[t]] = dp[t];
        cnt[p[t]] = 1;
      }
      int old = dp[p[t]];
      if (mx[p[t]] == -1) {
        dp[p[t]] = 1;
      } else if (cnt[p[t]] == 1 || p[t] == 1) {
        dp[p[t]] = mx[p[t]];
      } else {
        dp[p[t]] = mx[p[t]] + 1;
      }
      if (dp[p[t]] == old) break;
      t = p[t];
    }
    res.push_back(dp[1]);
  }
  PV((res).begin(), (res).end());
  return 0;
}
