#include <bits/stdc++.h>
using namespace std;
int n, a[200005], num[200005], vis[200005];
void dfs(int x, int t) {
  if (x > 0 && x <= n && (vis[x] == 0 || t < num[x])) {
    vis[x] = 1;
    num[x] = t;
  } else
    return;
  dfs(a[x], t + 1);
  dfs(x + 1, t + 1);
  dfs(x - 1, t + 1);
}
int main() {
  while (~scanf("%d", &n)) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    num[1] = 0;
    dfs(1, 0);
    for (int i = 1; i < n; i++) printf("%d ", num[i]);
    printf("%d\n", num[n]);
  }
}
