#include <bits/stdc++.h>
using namespace std;
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long INF = 1e9 + 9;
const long long MAXN = 3e5 + 1;
const long long MOD = 1e9 + 7;
const long double EPS = 1e-5;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> g(n, -1);
  for (long long i = 0; i < n; ++i) {
    cin >> g[i];
    --g[i];
  }
  vector<long long> d(n, INF);
  d[0] = 0;
  queue<long long> q;
  q.push(0);
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    if (d[v] + 1 < d[g[v]]) {
      d[g[v]] = d[v] + 1;
      q.push(g[v]);
    }
    if (v + 1 != n && d[v] + 1 < d[v + 1]) {
      d[v + 1] = d[v] + 1;
      q.push(v + 1);
    }
    if (v != 0 && d[v] + 1 < d[v - 1]) {
      d[v - 1] = d[v] + 1;
      q.push(v - 1);
    }
  }
  for (long long e : d) cout << e << ' ';
  return 0;
}
