#include <bits/stdc++.h>
using namespace std;
int i, n, a[200100], b[200100];
void fix(int v) {
  if (b[a[v]] > b[v] + 1) {
    b[a[v]] = b[v] + 1;
    fix(a[v]);
  }
  if (b[v + 1] > b[v] + 1) {
    b[v + 1] = b[v] + 1;
    fix(v + 1);
  }
  if (b[v - 1] > b[v] + 1) {
    b[v - 1] = b[v] + 1;
    fix(v - 1);
  }
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) b[i] = i;
  b[1] = 0;
  fix(1);
  for (i = 1; i <= n; i++) cout << b[i] << " ";
  return 0;
}
