#include <bits/stdc++.h>
using namespace std;
struct edge {
  int b, nt, w;
} e[400010 * 2];
int p[400010], nn;
int n;
void anode(int x, int y, int z) {
  nn++;
  e[nn].b = y;
  e[nn].w = z;
  e[nn].nt = p[x];
  p[x] = nn;
}
int in_queue[400010], dis[400010];
void spfa() {
  for (int i = 1; i <= n; i++) dis[i] = 1 << 29;
  queue<int> q;
  q.push(1);
  in_queue[1] = true;
  dis[1] = 0;
  while (!q.empty()) {
    int k = q.front();
    q.pop();
    in_queue[k] = false;
    for (int i = p[k]; i; i = e[i].nt) {
      int t = e[i].b;
      if (dis[t] > dis[k] + e[i].w) {
        dis[t] = dis[k] + e[i].w;
        if (!in_queue[t]) {
          q.push(t);
          in_queue[t] = true;
        }
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    anode(i, i + 1, 1);
    anode(i + 1, i, 1);
  }
  for (int i = 1; i <= n; i++) {
    int aa;
    scanf("%d", &aa);
    anode(i, aa, 1);
  }
  spfa();
  for (int i = 1; i <= n; i++) printf("%d ", dis[i]);
  return 0;
}
