#include <bits/stdc++.h>
using namespace std;
int a[200005];
int ans[200005];
int n;
void bfs() {
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (cur != 1) {
      if (ans[cur - 1] == 200005) {
        ans[cur - 1] = ans[cur] + 1;
        q.push(cur - 1);
      }
    }
    if (cur != n) {
      if (ans[cur + 1] == 200005) {
        ans[cur + 1] = ans[cur] + 1;
        q.push(cur + 1);
      }
    }
    if (ans[a[cur]] == 200005) {
      ans[a[cur]] = ans[cur] + 1;
      q.push(a[cur]);
    }
  }
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      ans[i] = 200005;
    }
    ans[1] = 0;
    bfs();
    for (int i = 1; i <= n; i++) {
      printf("%d ", ans[i]);
    }
    printf("\n");
  }
}
