#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T x, T y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    T f = x % y;
    x = y;
    y = f;
  }
  return x;
}
const int maxlog = 20;
const int maxn = 300003;
int lvl[maxn];
int P[maxn][maxlog];
int m;
int p1, p2;
void addChild(int child, int parent) {
  P[child][0] = parent;
  for (int i = 1; i < maxlog; i++) P[child][i] = P[P[child][i - 1]][i - 1];
  lvl[child] = lvl[parent] + 1;
}
int dist(int u, int v) {
  if (lvl[u] < lvl[v]) swap(u, v);
  int sm = lvl[u] + lvl[v];
  for (int i = maxlog - 1; i >= 0; i--)
    if (lvl[u] - lvl[v] >= (1 << i)) u = P[u][i];
  for (int i = maxlog - 1; i >= 0; i--)
    if (P[u][i] != P[v][i]) u = P[u][i], v = P[v][i];
  return sm - 2 * lvl[u == v ? u : P[u][0]];
}
void extend(int x, int& p1, set<int>& s1, int& p2, set<int>& s2) {
  int pd = dist(p1, p2);
  int x1d = dist(x, p1);
  if (x1d > pd) {
    for (auto i : s2)
      if (dist(i, x) == x1d) s1.insert(i);
    p2 = x;
    s2 = {x};
    return;
  }
  int x2d = dist(x, p2);
  if (x2d > pd) {
    for (auto i : s1)
      if (dist(i, x) == x2d) s2.insert(i);
    p1 = x;
    s1 = {x};
    return;
  }
  if (x1d == pd) {
    s2.insert(x);
  } else if (x2d == pd) {
    s1.insert(x);
  }
}
int main(int argc, char* argv[]) {
  std::cin.sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> m;
  {
    int x = 2, y;
    lvl[1] = 1;
    m--;
    cin >> y;
    if (y != 1) exit(-1);
    cout << 2 << endl;
    addChild(2, 1);
    p1 = 1;
    p2 = 2;
    set<int> s1 = {1}, s2 = {2};
    while (m-- > 0) {
      x++;
      cin >> y;
      addChild(x, y);
      extend(x, p1, s1, p2, s2);
      cout << (s1.size() + s2.size()) << endl;
    }
  }
  return 0;
}
