#include <bits/stdc++.h>
using namespace std;
int n;
int a[200000];
vector<int> solve() {
  vector<bool> discovered(n, false);
  queue<pair<int, int>> q;
  vector<int> order(n);
  discovered[0] = true;
  pair<int, int> elt(0, 0);
  q.push(elt);
  while (!q.empty()) {
    pair<int, int> here = q.front();
    q.pop();
    order[here.first] = here.second;
    if (here.first > 0 && !discovered[here.first - 1]) {
      pair<int, int> elt2(here.first - 1, here.second + 1);
      q.push(elt2);
      discovered[elt2.first] = true;
    }
    if (here.first < n - 1 && !discovered[here.first + 1]) {
      pair<int, int> elt3(here.first + 1, here.second + 1);
      q.push(elt3);
      discovered[elt3.first] = true;
    }
    if (!discovered[a[here.first]]) {
      pair<int, int> elt4(a[here.first], here.second + 1);
      q.push(elt4);
      discovered[elt4.first] = true;
    }
  }
  return order;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> ans = solve();
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
