#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int head[N], cnt;
struct edge {
  int n, t;
  edge(int a = 0, int b = 0) : n(a), t(b) {}
} e[N * 3];
void ins(int a, int b) {
  e[cnt] = edge(head[a], b);
  head[a] = cnt++;
}
int n, len[N];
queue<int> que;
void bfs() {
  que.push(1);
  int u, i, v;
  while (!que.empty()) {
    u = que.front();
    que.pop();
    for (i = head[u]; i != -1; i = e[i].n) {
      v = e[i].t;
      if (len[v] >= 0) continue;
      len[v] = len[u] + 1;
      que.push(v);
    }
  }
}
int main() {
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  memset(len, -1, sizeof(len));
  cnt = len[1] = 0;
  int i, j;
  for (i = 1; i < n; ++i) ins(i, i + 1), ins(i + 1, i);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &j);
    ins(i, j);
  }
  bfs();
  for (int i = 1; i <= n; ++i) printf("%d%c", len[i], i == n ? '\n' : ' ');
  return 0;
}
