#include <bits/stdc++.h>
using namespace std;
int main() {
  int curto[200200];
  bool flag[200200] = {false};
  int dist[200200];
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &curto[i]);
    dist[i] = 999999999;
  }
  dist[1] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      fila;
  fila.push(pair<int, int>(0, 1));
  while (!fila.empty()) {
    int x = fila.top().second;
    int z = fila.top().first;
    fila.pop();
    if (dist[x] != z) continue;
    int y = x + 1;
    if (y <= n && dist[y] > dist[x] + 1) {
      dist[y] = dist[x] + 1;
      fila.push(pair<int, int>(dist[y], y));
    }
    y = x - 1;
    if (y > 0 && dist[y] > dist[x] + 1) {
      dist[y] = dist[x] + 1;
      fila.push(pair<int, int>(dist[y], y));
    }
    y = curto[x];
    if (dist[y] > dist[x] + 1) {
      dist[y] = dist[x] + 1;
      fila.push(pair<int, int>(dist[y], y));
    }
  }
  printf("%d", dist[1]);
  for (int i = 2; i <= n; i++) {
    printf(" %d", dist[i]);
  }
  printf("\n");
}
