#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> ans(n, 0);
  vector<int> visited(n, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v[i] = a - 1;
    ans[i] = i;
  }
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  visited[0] = 1;
  while (q.size() > 0) {
    pair<int, int> p = q.front();
    q.pop();
    ans[p.first] = p.second;
    if (visited[v[p.first]] == 0) {
      visited[v[p.first]] = 1;
      q.push(make_pair(v[p.first], p.second + 1));
    }
    if (p.first + 1 < n && visited[p.first + 1] == 0) {
      visited[p.first + 1] = 1;
      q.push(make_pair(p.first + 1, p.second + 1));
    }
    if (p.first - 1 >= 0 && visited[p.first - 1] == 0) {
      visited[p.first - 1] = 1;
      q.push(make_pair(p.first - 1, p.second + 1));
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
