#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
vector<int> adj[MAXN + 1];
int dist[MAXN + 1];
void bfs(int _v) {
  queue<int> q;
  q.push(_v);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : adj[v]) {
      if (dist[u] == 0 && u != _v && u != v) {
        dist[u] = dist[v] + 1;
        q.push(u);
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    if (i > 1) {
      adj[i - 1].push_back(i);
      adj[i].push_back(i - 1);
    }
    adj[i].push_back(a);
  }
  bfs(1);
  for (int i = 1; i <= n; i++) printf("%d ", dist[i]);
  return 0;
}
