#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long base = 1e9;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 10;
vector<long long> g[N];
long long n, d[N];
bool vis[N];
void solve();
void bfs(long long s);
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
void solve() {
  cin >> n;
  for (long long i = 1, a; i <= n; ++i) {
    cin >> a;
    if (a > i) {
      g[i].push_back(a);
    }
  }
  for (long long i = 1; i <= n - 1; ++i) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  bfs(1);
  for (long long i = 1; i <= n; ++i) {
    cout << d[i] << " ";
  }
  cout << "\n";
  return;
}
void bfs(long long s) {
  queue<long long> q;
  q.push(s);
  vis[s] = true;
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    for (auto &x : g[v]) {
      if (!vis[x]) {
        vis[x] = true;
        q.push(x);
        d[x] = d[v] + 1;
      }
    }
  }
  return;
}
