#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int dis[maxn], num[maxn];
int n;
void bfs() {
  memset(dis, -1, sizeof(dis));
  dis[1] = 0;
  queue<int> que;
  que.push(1);
  while (!que.empty()) {
    int q = que.front();
    que.pop();
    for (int i = -1; i <= 1; i++) {
      if (i == 0) continue;
      int d = q + i;
      if (1 <= d && d <= n && dis[d] == -1) {
        dis[d] = dis[q] + 1;
        que.push(d);
      }
    }
    int d = num[q];
    if (dis[d] == -1) {
      dis[d] = dis[q] + 1;
      que.push(d);
    }
  }
  return;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &num[i]);
    }
    bfs();
    printf("%d", dis[1]);
    for (int i = 2; i <= n; i++) printf(" %d", dis[i]);
    printf("\n");
  }
  return 0;
}
