#include <bits/stdc++.h>
using namespace std;
int n;
int short_path[200010];
int ans[200010];
int flag;
struct NODE {
  int num, step;
};
struct cmp {
  bool operator()(NODE &a, NODE &b) { return a.step > b.step; }
};
void bfs() {
  NODE now, next;
  priority_queue<NODE, vector<NODE>, cmp> q;
  now.num = 1;
  now.step = 0;
  q.push(now);
  while (!q.empty()) {
    now = q.top();
    q.pop();
    if (ans[now.num] != -1) continue;
    ans[now.num] = now.step;
    flag++;
    if (flag == n) return;
    for (int i = 1; i <= 3; i++) {
      next.step = now.step + 1;
      if (i == 1)
        next.num = now.num - 1;
      else if (i == 2)
        next.num = now.num + 1;
      else if (i == 3)
        next.num = short_path[now.num];
      if (ans[next.num] == -1 && next.num > 0 && next.num <= n) q.push(next);
    }
  }
}
int main() {
  while (cin >> n) {
    flag = 0;
    memset(ans, -1, sizeof(ans));
    for (int i = 1; i <= n; i++) cin >> short_path[i];
    bfs();
    cout << ans[1];
    for (int i = 2; i <= n; i++) cout << ' ' << ans[i];
    cout << endl;
  }
  return 0;
}
