#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 1e5;
vector<int> g[MAXN];
bool used[MAXN];
int dist[MAXN];
void bfs(int s) {
  queue<int> q;
  used[s] = true;
  q.push(s);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto &u : g[v]) {
      if (!used[u]) {
        used[u] = true;
        dist[u] = dist[v] + 1;
        q.push(u);
      }
    }
  }
}
signed main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    --a;
    g[i].push_back(a);
    if (i != 0) {
      g[i].push_back(i - 1);
      g[i - 1].push_back(i);
    }
  }
  bfs(0);
  for (int i = 0; i < n; ++i) {
    cout << dist[i] << ' ';
  }
  cout << '\n';
}
