#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> v(n), d(n);
  queue<int> q;
  q.push(0);
  v[0] = 1;
  int l = 0;
  while (!q.empty()) {
    int nn = q.size();
    while (nn-- > 0) {
      int t = q.front();
      q.pop();
      d[t] = l;
      if (t > 0 && v[t - 1] == 0) {
        q.push(t - 1);
        v[t - 1] = 1;
      }
      if (t < n - 1 && v[t + 1] == 0) {
        q.push(t + 1);
        v[t + 1] = 1;
      }
      if (v[a[t]] == 0) {
        q.push(a[t]);
        v[a[t]] = 1;
      }
    }
    l++;
  }
  for (int i : d) cout << i << " ";
  cout << endl;
  return 0;
}
