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