#include <bits/stdc++.h>
using namespace std;
struct node {
  list<int> next;
  bool visited = false;
};
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> dist(n);
  vector<node> graph(n);
  queue<int> unvisited;
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    temp--;
    if (i != temp) {
      graph[i].next.push_back(temp);
    }
    if (i - 1 >= 0 && temp != i - 1) {
      graph[i].next.push_back(i - 1);
    }
    if (i + 1 < n && temp != i + 1) {
      graph[i].next.push_back(i + 1);
    }
    dist[i] = i;
  }
  unvisited.push(0);
  while (!unvisited.empty()) {
    int front = unvisited.front();
    unvisited.pop();
    graph[front].visited = true;
    list<int>::iterator it = graph[front].next.begin();
    for (; it != graph[front].next.end(); ++it) {
      if (dist[*it] > dist[front] + 1) {
        dist[*it] = dist[front] + 1;
      }
      if (graph[*it].visited == false) {
        graph[*it].visited = true;
        unvisited.push(*it);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << dist[i] << ' ';
  }
  cout << endl;
  return 0;
}
