#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e+4;
const int MAXM = 1e+5;
const int INF = numeric_limits<int>::max();
const long long LL_INF = numeric_limits<long long>::max();
int n;
int to[2 * MAXM + 10][3];
int ans[2 * MAXM + 10];
struct Q {
  int s, t;
};
void bfs(int st) {
  ans[st] = 0;
  queue<Q> que;
  while (!que.empty()) que.pop();
  Q now, next;
  now.s = st;
  now.t = 0;
  que.push(now);
  while (!que.empty()) {
    now = que.front();
    que.pop();
    for (int i = 0; i < 3; i++) {
      next.s = to[now.s][i];
      next.t = now.t + 1;
      if (next.s < 1 || next.s > n) continue;
      if (next.t < ans[next.s]) {
        ans[next.s] = next.t;
        que.push(next);
      }
    }
  }
  return;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &to[i][1]);
      to[i][0] = i + 1;
      to[i][2] = i - 1;
    }
    for (int i = 0; i <= n; i++) ans[i] = (1 << 30);
    bfs(1);
    for (int i = 1; i <= n; i++) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  }
  return 0;
}
