#include <bits/stdc++.h>
const int SIZE = 200010;
int way[SIZE];
int result[SIZE];
bool visited[SIZE];
int count;
std::queue<int> q;
bool ok(int pos) {
  if (visited[pos]) {
    return false;
  }
  return true;
}
void bfs() {
  memset(visited, false, sizeof(visited));
  q.push(1);
  result[1] = 0;
  visited[0] = visited[1] = visited[count + 1] = true;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    if (ok(now - 1)) {
      q.push(now - 1);
      visited[now - 1] = true;
      result[now - 1] = result[now] + 1;
    }
    if (ok(now + 1)) {
      q.push(now + 1);
      visited[now + 1] = true;
      result[now + 1] = result[now] + 1;
    }
    if (ok(way[now])) {
      q.push(way[now]);
      visited[way[now]] = true;
      result[way[now]] = result[now] + 1;
    }
  }
}
int main() {
  std::cin >> count;
  for (int i = 1; i <= count; ++i) {
    std::cin >> way[i];
  }
  bfs();
  std::cout << result[1];
  for (int i = 2; i <= count; ++i) {
    std::cout << " " << result[i];
  }
  std::cout << std::endl;
  return 0;
}
