#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int OO = 1e9;
const int N = 1e6 + 10, M = N << 1;
int n, m, k, T;
int a, b, c;
struct ADJ {
  int head[N], nxt[M], to[M], n, ne;
  void init(int nNodes) {
    ne = 0;
    n = nNodes;
    memset(head, -1, n * sizeof head[0]);
  }
  void addEdge(int f, int t) {
    to[ne] = t;
    nxt[ne] = head[f];
    head[f] = ne++;
  }
  void addBiEdge(int u, int v) {
    addEdge(u, v);
    addEdge(v, u);
  }
  int addNode() {
    head[n] = -1;
    return n++;
  }
} adj;
struct LCA {
  struct SegmentTree {
    vector<pair<int, int> > seg;
    int n;
    void init(vector<pair<int, int> > &tour) {
      n = (int)(tour.size());
      seg = vector<pair<int, int> >(n << 2);
      Bulid(0, n - 1, 1, tour);
    }
    void Bulid(int l, int r, int pos, vector<pair<int, int> > &tour) {
      if (l == r) {
        seg[pos] = tour[l];
        return;
      }
      int mid = (l + r) >> 1;
      Bulid(l, mid, pos << 1, tour);
      Bulid(mid + 1, r, pos << 1 | 1, tour);
      seg[pos] = min(seg[pos << 1], seg[pos << 1 | 1]);
    }
    pair<int, int> Query(int l, int r, int pos, int st, int en) {
      if (st > r || en < l || st > en) return make_pair(1e9, 1e9);
      if (l >= st && r <= en) return seg[pos];
      int mid = (l + r) >> 1;
      pair<int, int> lt = Query(l, mid, pos << 1, st, en);
      pair<int, int> rt = Query(mid + 1, r, pos << 1 | 1, st, en);
      return min(lt, rt);
    }
    pair<int, int> Query(int st, int en) { return Query(0, n - 1, 1, st, en); }
  } ST;
  int root, n;
  vector<int> depth, firstIn;
  vector<pair<int, int> > tour;
  void init(int root_) {
    root = root_;
    n = adj.n;
    depth = firstIn = vector<int>(n, -1);
    DFS(root, -1, 0);
    ST.init(tour);
  }
  void DFS(int u, int p, int d) {
    depth[u] = d;
    firstIn[u] = (int)tour.size();
    tour.push_back(make_pair(depth[u], u));
    for (int e = adj.head[u], v; ~e && (v = adj.to[e], 1); e = adj.nxt[e]) {
      if (v == p) continue;
      DFS(v, u, d + 1);
      tour.push_back(make_pair(depth[u], u));
    }
  }
  int get_LCA(int u, int v) {
    if (firstIn[u] > firstIn[v]) swap(u, v);
    return ST.Query(firstIn[u], firstIn[v]).second;
  }
  int get_Distance(int u, int v) {
    int lca = get_LCA(u, v);
    return depth[u] + depth[v] - (depth[lca] << 1);
  }
} Tree;
int arr[N];
struct Node {
  unordered_map<int, int> mp;
  int mxD;
  Node() { mxD = 0; }
} res[N];
struct CentroidDecomposition {
  int sz[N], centerPar[N], vis[N], vid;
  ADJ adj;
  void init(ADJ &a) {
    vid++;
    adj = a;
  }
  int CalcSZ(int u, int p) {
    sz[u] = 1;
    for (int e = adj.head[u], v; ~e && (v = adj.to[e], 1); e = adj.nxt[e]) {
      if (v == p || vis[v] == vid) continue;
      sz[u] += CalcSZ(v, u);
    }
    return sz[u];
  }
  int Centroid(int u, int p, int compSz) {
    for (int e = adj.head[u], v; ~e && (v = adj.to[e], 1); e = adj.nxt[e]) {
      if (v == p || vis[v] == vid) continue;
      if ((sz[v] << 1) > compSz) return Centroid(v, u, compSz);
    }
    return u;
  }
  void Bulid(int u, int p) {
    int compSz = CalcSZ(u, p);
    int center = Centroid(u, p, compSz);
    centerPar[center] = p;
    sz[center] = compSz;
    vis[center] = vid;
    for (int e = adj.head[center], v; ~e && (v = adj.to[e], 1);
         e = adj.nxt[e]) {
      if (vis[v] == vid) continue;
      Bulid(v, center);
    }
  }
} CD;
int main() {
  adj.init(4);
  adj.addBiEdge(0, 1);
  adj.addBiEdge(0, 2);
  adj.addBiEdge(0, 3);
  scanf("%d", &n);
  int u;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &u);
    --u;
    int a = adj.addNode(), b = adj.addNode();
    arr[i] = a;
    adj.addBiEdge(u, a);
    adj.addBiEdge(u, b);
  }
  assert(adj.n < N);
  Tree.init(0);
  int a = 1, b = 2;
  for (int i = 0; i < n; ++i) {
    int u = arr[i];
    res[i].mxD = -1;
    CD.sz[i] = CD.vis[i] = -2;
    int len = Tree.get_Distance(a, b);
    int x1 = Tree.get_Distance(a, u);
    int x2 = Tree.get_Distance(b, u);
    if (x1 >= x2 && x1 > len) {
      len = x1;
      b = u;
    } else if (x2 >= x1 && x2 > len) {
      len = x2;
      a = u;
    }
    printf("%d\n", len);
  }
  return 0;
}
