#include <bits/stdc++.h>
using namespace std;
const int inf = 987654321;
const long long int INF = 123456789987654321;
const long long int mod = 1000000009;
int N;
vector<int> arr;
vector<vector<int> > inv;
int main() {
  cin >> N;
  arr.resize(N);
  inv.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  vector<int> ans(N, inf);
  ans[0] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int fq = q.front();
    q.pop();
    if (fq - 1 >= 0 && ans[fq - 1] == inf) {
      q.push(fq - 1);
      ans[fq - 1] = ans[fq] + 1;
    }
    if (fq + 1 < N && ans[fq + 1] == inf) {
      q.push(fq + 1);
      ans[fq + 1] = ans[fq] + 1;
    }
    if (arr[fq] != fq && ans[arr[fq]] == inf) {
      q.push(arr[fq]);
      ans[arr[fq]] = ans[fq] + 1;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << ' ';
  }
}
