#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int dis[200001];
int color[200001];
void bfs() {
  queue<int> q;
  q.push(1);
  dis[1] = 0;
  color[1] = 1;
  int u, temp, i;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (i = 0; i < adj[u].size(); i++) {
      temp = adj[u][i];
      if (color[temp] == 0) {
        q.push(temp);
        color[temp] = 1;
        dis[temp] = dis[u] + 1;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  int a, i;
  for (i = 0; i <= n; i++) {
    dis[i] = color[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    cin >> a;
    if (a != i) adj[i].push_back(a);
    if (a != i - 1) adj[i].push_back(i - 1);
    if (a != i + 1) adj[i].push_back(i + 1);
  }
  bfs();
  for (i = 1; i <= n; i++) cout << dis[i] << " ";
  return 0;
}
