#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 28;
const long long LINF = 1ll << 61;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c != ' ' && c != '\n') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
inline char mygetchar() {
  register char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
int n;
int p[20][200111];
int dis[200111];
int getlca(int x, int y) {
  if (dis[x] < dis[y]) swap(x, y);
  for (int i = 19; i >= 0; i--) {
    if (p[i][x] != -1 && dis[p[i][x]] >= dis[y]) {
      x = p[i][x];
    }
  }
  if (x == y) return x;
  for (int i = 19; i >= 0; i--) {
    if (p[i][x] != p[i][y]) {
      x = p[i][x];
      y = p[i][y];
    }
  }
  return p[0][x];
}
int main() {
  n = getnum();
  for (int i = 0; i < 20; i++) p[i][1] = -1;
  int mxid = 1, mx = 0, ans = 0;
  for (int i = 2; i <= n; i++) {
    int x;
    x = getnum();
    dis[i] = dis[x] + 1;
    if (dis[i] > mx) {
      mxid = i;
      mx = dis[i];
      ans++;
    }
    p[0][i] = x;
    for (int j = 1; j < 20; j++) {
      p[j][i] = p[j - 1][p[j - 1][i]];
    }
    int tmp = getlca(i, mxid);
    ans = max(ans, dis[i] + dis[mxid] - 2 * dis[tmp]);
    putnum(ans), putendl();
  }
  return 0;
}
