#include <bits/stdc++.h>
using namespace std;
int arr[200010];
int err[200010];
int black[200010];
queue<int> d;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    err[i] = n + 5;
  }
  while (!d.empty()) d.pop();
  d.push(1);
  int lv = 0;
  while (!d.empty()) {
    int siz = d.size();
    for (int i = 0; i < siz; i++) {
      int fr = d.front();
      d.pop();
      err[fr] = min(err[fr], lv);
      black[fr] = 1;
      if (fr - 1 > 0 && black[fr - 1] == 0) d.push(fr - 1), black[fr - 1] = 1;
      if (fr + 1 <= n && black[fr + 1] == 0) d.push(fr + 1), black[fr + 1] = 1;
      if (arr[fr] > 0 && black[arr[fr]] == 0)
        d.push(arr[fr]), black[arr[fr]] = 1;
    }
    lv++;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", err[i]);
  }
  return 0;
}
