#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
const int ninf = -(1e9);
struct node {
  int c, mx, lazy;
  node() { c = mx = lazy = 0; }
  node(int x, int y, int z) {
    c = x;
    mx = y;
    lazy = z;
  }
};
node *tree;
node mergem(node &x, node a, node b) {
  assert(!x.lazy && !a.lazy && !b.lazy);
  int lol = max(a.mx, b.mx);
  x.c = 0;
  x.mx = lol;
  if (a.mx == lol) {
    x.c += a.c;
  }
  if (b.mx == lol) {
    x.c += b.c;
  }
  return x;
}
void propa(int nod, int a, int b) {
  if (tree[nod].lazy != 0) {
    tree[nod].mx += tree[nod].lazy;
    int lc = (nod << 1), rc = lc | 1, mid = (a + b) >> 1;
    if (a < b) {
      tree[lc].lazy += tree[nod].lazy;
      tree[rc].lazy += tree[nod].lazy;
    }
    tree[nod].lazy = 0;
  }
}
int ord[300010], m, n;
int dp[300010][20], lgn, lev[300010];
void btree(int nod, int a, int b) {
  if (a == b) {
    tree[nod].mx = ninf;
    tree[nod].c = 1;
    return;
  }
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc | 1;
  btree(lc, a, mid);
  btree(rc, mid + 1, b);
  mergem(tree[nod], tree[lc], tree[rc]);
}
void upd(int nod, int a, int b, int x, int y, int val) {
  assert(a <= b);
  propa(nod, a, b);
  if (a > b || a > y || b < x) {
    return;
  }
  if (x <= a && b <= y) {
    tree[nod].lazy += val;
    propa(nod, a, b);
    return;
  }
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc | 1;
  upd(lc, a, mid, x, y, val);
  upd(rc, mid + 1, b, x, y, val);
  mergem(tree[nod], tree[lc], tree[rc]);
}
node que(int nod, int a, int b, int x, int y) {
  assert(a <= b);
  propa(nod, a, b);
  if (a > b || a > y || b < x) {
    return (node){0, 2 * ninf, 0};
  }
  if (x <= a && b <= y) {
    return tree[nod];
  }
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc | 1;
  node ret;
  mergem(ret, que(lc, a, mid, x, y), que(rc, mid + 1, b, x, y));
  return ret;
}
vector<int> gr[300010];
int tim = 0, st[300010], en[300010];
void dfs(int c, int p) {
  st[c] = ++tim;
  int i, z = gr[c].size();
  for (i = 0; i < z; i++) {
    if (gr[c][i] != p) dfs(gr[c][i], c);
  }
  en[c] = tim;
}
inline void pre();
inline int lca(int a, int b);
int dist(int a, int b) {
  static int cc;
  cc = lca(a, b);
  return lev[a] + lev[b] - (2 * lev[cc]);
}
int c1, c2, f = 0;
int e1 = 1, e2 = 1, dia = 0;
int jumpto(int x, int up) {
  int i;
  for (i = lgn; i >= 0; i--) {
    if (up & (1 << i)) {
      x = dp[x][i];
    }
  }
  assert(x > 0);
  return x;
}
int main() {
  tree = new node[4 * 300010];
  scanf("%d", &m);
  n = m + 1;
  int i, j;
  lev[1] = 1;
  for (i = 2; i <= n; i++) {
    scanf("%d", &ord[i]);
    dp[i][0] = ord[i];
    lev[i] = lev[ord[i]] + 1;
    gr[i].push_back(ord[i]);
    gr[ord[i]].push_back(i);
  }
  dfs(1, 0);
  pre();
  btree(1, 1, n);
  c1 = 1;
  f = 0;
  dia = 0;
  upd(1, 1, n, st[1], st[1], 0 - ninf);
  for (i = 2; i <= n; i++) {
    {
      node gag = que(1, 1, n, st[i], st[i]);
      int got = gag.mx;
      int tobe;
      if (f == 0) {
        tobe = dist(i, c1);
      } else
        tobe = min(dist(i, c1), dist(i, c2));
      upd(1, 1, n, st[i], st[i], tobe - que(1, 1, n, st[i], st[i]).mx);
    }
    int d1 = dist(e1, i);
    int d2 = dist(e2, i);
    int dd = max(d1, d2);
    if (d1 < d2) {
      swap(e1, e2);
      swap(d1, d2);
    }
    if (dia >= dd) {
      printf("%d\n", que(1, 1, n, 1, n).c);
      continue;
    }
    dia = dd;
    int cc = lca(i, e1);
    if (f == 1) {
      if (dp[c2][0] != c1) {
        swap(c1, c2);
      }
      assert(dp[c2][0] == c1);
    }
    if (f == 0) {
      assert(dd % 2 == 1);
      int alpha;
      if (lev[e1] > lev[i]) {
        alpha = jumpto(e1, dd / 2);
      } else
        alpha = jumpto(i, dd / 2);
      if (alpha == c1) {
        alpha = dp[c1][0];
      }
      c2 = alpha;
      if (dp[c2][0] == c1) {
        upd(1, 1, n, st[c2], en[c2], -1);
      } else {
        upd(1, 1, n, 1, n, -1);
        upd(1, 1, n, st[c1], en[c1], +1);
      }
    } else {
      assert(f == 1);
      if (dist(i, c1) > dist(i, c2)) {
        swap(c1, c2);
      }
      if (dp[c2][0] == c1) {
        upd(1, 1, n, st[c2], en[c2], +1);
      } else {
        upd(1, 1, n, 1, n, +1);
        upd(1, 1, n, st[c1], en[c1], -1);
      }
    }
    f ^= 1;
    node fin = que(1, 1, n, 1, n);
    e2 = i;
    printf("%d\n", fin.c);
  }
  return 0;
}
inline void pre() {
  for (lgn = 0; (1 << lgn) <= n; lgn++)
    ;
  for (int j = 1; j <= lgn; j++)
    for (int i = 1; i <= n; i++) dp[i][j] = dp[dp[i][j - 1]][j - 1];
}
inline int lca(int a, int b) {
  if (a == b) return a;
  if (lev[a] < lev[b]) swap(a, b);
  int i, j;
  if (lev[a] > lev[b])
    for (i = lgn; i >= 0; i--)
      if (lev[a] - (1 << i) >= lev[b]) a = dp[a][i];
  if (a == b) return a;
  for (i = lgn; i >= 0; i--)
    if (dp[a][i] != dp[b][i]) {
      a = dp[a][i];
      b = dp[b][i];
    }
  return dp[a][0];
}
