#include <bits/stdc++.h>
using namespace ::std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const long long inf = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(0.0) * 2.0;
const double eps = 1e-8;
const int maxn = 2e5 + 10;
const int maxm = 2e6 + 10;
const int mod = 1e9 + 7;
int n, g[maxn], d[maxn], vis[maxn];
queue<int> q;
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &g[i]);
}
int f(int x, int k) {
  if (k == 1) return g[x];
  if (k == 2) return x - 1;
  if (k == 3) return x + 1;
}
void bfs() {
  memset(vis, 0, sizeof(vis));
  while (q.size()) q.pop();
  q.push(1);
  d[1] = 0;
  vis[1] = 1;
  while (q.size()) {
    int p = q.front();
    q.pop();
    for (int i = 1; i <= 3; i++) {
      int nx = f(p, i);
      if (1 <= nx && nx <= n && vis[nx] == 0) {
        q.push(nx);
        d[nx] = d[p] + 1;
        vis[nx] = 1;
      }
    }
  }
}
void solve() {
  bfs();
  for (int i = 1; i < n; i++) printf("%d ", d[i]);
  printf("%d\n", d[n]);
}
int main() {
  init();
  solve();
  return 0;
}
