#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') {
    w = (w << 3) + (w << 1) + (ch ^ 48);
    ch = getchar();
  }
  return w;
}
int n, s1[300100], s2[300100], d[300100], f[300100][31], tot = 1, top1, top2,
                                                         dm;
inline int add(int x) {
  int y = ++tot;
  f[y][0] = x;
  d[y] = d[x] + 1;
  for (int i = 1; i <= log2(d[y]) + 1; i++) f[y][i] = f[f[y][i - 1]][i - 1];
  return y;
}
inline int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  for (int i = log2(d[x] - d[y]); i >= 0; i--)
    if (d[f[x][i]] >= d[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = log2(d[x]); i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
inline int dis(int x, int y) { return d[x] + d[y] - d[lca(x, y)] * 2; }
int main() {
  n = read();
  s1[++top1] = 1;
  for (int i = 1; i <= n; i++) {
    int x = read();
    x = add(x);
    int d1 = top1 ? dis(x, s1[top1]) : 0;
    int d2 = top2 ? dis(x, s2[top2]) : 0;
    if (d1 > dm) {
      dm = d1;
      for (int i = 1; i <= top2; i++)
        if (dis(s2[i], x) == dm) s1[++top1] = s2[i];
      top2 = 0;
    } else if (d2 > dm) {
      dm = d2;
      for (int i = 1; i <= top1; i++)
        if (dis(s1[i], x) == dm) s2[++top2] = s1[i];
      top1 = 0;
    }
    if (d1 == dm)
      s2[++top2] = x;
    else if (d2 == dm)
      s1[++top1] = x;
    printf("%d\n", top1 + top2);
  }
  return 0;
}
