#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
class dfstream {
 public:
  dfstream& operator<<(int n) {
    cout << n;
    return *this;
  }
  dfstream& operator<<(long long n) {
    cout << n;
    return *this;
  }
  dfstream& operator<<(string s) {
    cout << s;
    return *this;
  }
  dfstream& operator<<(char s[]) {
    cout << s;
    return *this;
  }
  dfstream& operator<<(double n) {
    cout << n;
    return *this;
  }
  dfstream& operator<<(vector<int> n) {
    for (auto i : n) {
      cout << i << " ";
    }
    return *this;
  }
  dfstream& operator<<(vector<long long> n) {
    for (auto i : n) {
      cout << i << " ";
    }
    return *this;
  }
  dfstream& operator<<(vector<double> n) {
    for (auto i : n) {
      cout << i << " ";
    }
    return *this;
  }
  dfstream& operator<<(set<int> n) {
    for (auto i : n) {
      cout << i << " ";
    }
    return *this;
  }
  dfstream& operator<<(set<long long> n) {
    for (auto i : n) {
      cout << i << " ";
    }
    return *this;
  }
  dfstream& operator<<(set<double> n) {
    for (auto i : n) {
      cout << i << " ";
    }
    return *this;
  }
} dout;
void DEBUG(string name, int* begin, int* end) {
  printf("DEBUG: %s = {", name.c_str());
  for (; begin != end; begin++) {
    printf("%5d,", *begin);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, long long* begin, long long* end) {
  printf("DEBUG: %s = {", name.c_str());
  for (; begin != end; begin++) {
    printf("%5lld,", *begin);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, double* begin, double* end) {
  printf("DEBUG: %s = {", name.c_str());
  for (; begin != end; begin++) {
    printf("%5lf,", *begin);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, vector<int> nums) {
  printf("DEBUG: %s = {", name.c_str());
  for (int i : nums) {
    printf("%5d,", i);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, set<int> nums) {
  printf("DEBUG: %s = {", name.c_str());
  for (int i : nums) {
    printf("%5d,", i);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, vector<long long> nums) {
  printf("DEBUG: %s = {", name.c_str());
  for (int i : nums) {
    printf("%5lld,", i);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, set<long long> nums) {
  printf("DEBUG: %s = {", name.c_str());
  for (int i : nums) {
    printf("%5lld,", i);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, map<int, int> nums) {
  printf("DEBUG: %s = {", name.c_str());
  for (auto i : nums) {
    printf("(%d -> %d),", i.first, i.second);
  }
  printf("%c}\n", (char)8);
}
void DEBUG(string name, queue<int> nums) {
  if (nums.size() == 0) {
    printf("DEBUG: %s = []\n", name.c_str());
    return;
  }
  printf("DEBUG: %s = [", name.c_str());
  while (!nums.empty()) {
    printf("%5d,", nums.front());
    nums.pop();
  }
  printf("%c]\n", (char)8);
}
void DEBUG(string name, int num) {
  printf("DEBUG: %s = %d\n", name.c_str(), num);
}
void DEBUG(string name, long long num) {
  printf("DEBUG: %s = %lld\n", name.c_str(), num);
}
void DEBUG(string name, double num) {
  printf("DEBUG: %s = %lf\n", name.c_str(), num);
}
int cross(int a1, int b1, int a2, int b2) { return (a1 * b2 - a2 * b1); }
int ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  return cross(b.first - a.first, b.second - a.second, c.first - a.first,
               c.second - a.second);
}
void hi() { printf("hi\n"); }
int parent[2 * 500010][25], depths[2 * 500010];
bool visited[2 * 500010];
vector<int> adj[2 * 500010];
void dfs(int cnode) {
  for (int i = 0; i < adj[cnode].size(); i++) {
    if (!visited[adj[cnode][i]]) {
      parent[adj[cnode][i]][0] = cnode;
      depths[adj[cnode][i]] = depths[cnode] + 1;
      visited[adj[cnode][i]] = true;
      dfs(adj[cnode][i]);
    }
  }
}
int jump(int a, int len) {
  int res = a;
  assert(depths[a] >= len);
  for (int i = 20; i >= 0; i--) {
    int x = depths[res];
    if ((1 << i) <= len) {
      res = parent[res][i];
      len -= 1 << i;
    }
  }
  assert(len == 0);
  return res;
}
int lca(int a, int b) {
  if (depths[a] < depths[b]) {
    b = jump(b, depths[b] - depths[a]);
  } else if (depths[b] < depths[a]) {
    a = jump(a, depths[a] - depths[b]);
  }
  if (a == b) {
    return a;
  }
  assert(depths[a] == depths[b]);
  for (int i = 20; i >= 0; i--) {
    if (parent[a][i] != parent[b][i]) {
      a = parent[a][i];
      b = parent[b][i];
    }
  }
  assert(parent[a][0] == parent[b][0]);
  return parent[a][0];
}
int dist(int a, int b) { return depths[a] + depths[b] - 2 * depths[lca(a, b)]; }
int main() {
  memset(parent, -1, sizeof(parent));
  adj[0].push_back(1);
  adj[0].push_back(3);
  adj[0].push_back(2);
  visited[0] = true;
  dfs(0);
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 25; j++) {
      if (parent[i][j - 1] == -1) break;
      parent[i][j] = parent[parent[i][j - 1]][j - 1];
    }
  }
  int n;
  scanf("%d", &n);
  int curr_x = 2, curr_y = 1;
  int curr_node = 4;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    parent[curr_node][0] = x;
    parent[curr_node + 1][0] = x;
    depths[curr_node] = depths[curr_node + 1] = depths[x] + 1;
    for (int j = 1; j < 22; j++) {
      if (parent[curr_node][j - 1] == -1) break;
      parent[curr_node][j] = parent[parent[curr_node][j - 1]][j - 1];
    }
    for (int j = 1; j < 22; j++) {
      if (parent[curr_node + 1][j - 1] == -1) break;
      parent[curr_node + 1][j] = parent[parent[curr_node + 1][j - 1]][j - 1];
    }
    if (dist(curr_node, curr_x) > dist(curr_x, curr_y)) {
      curr_y = curr_node;
    }
    if (dist(curr_node, curr_y) > dist(curr_x, curr_y)) {
      curr_x = curr_node;
    }
    if (dist(curr_node + 1, curr_x) > dist(curr_x, curr_y)) {
      curr_y = curr_node + 1;
    }
    if (dist(curr_node + 1, curr_y) > dist(curr_x, curr_y)) {
      curr_x = curr_node + 1;
    }
    curr_node += 2;
    printf("%d\n", dist(curr_x, curr_y));
  }
  return 0;
}
