#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
int visited[MAX];
int a[MAX], dis[MAX];
int n;
void bfs() {
  queue<int> q;
  int b;
  visited[1] = 1;
  dis[1] = 0;
  q.push(1);
  while (!q.empty()) {
    b = q.front();
    q.pop();
    if (!visited[b + 1] && b + 1 <= n) {
      visited[b + 1] = 1;
      dis[b + 1] = dis[b] + 1;
      q.push(b + 1);
    }
    if (!visited[b - 1] && b - 1 > 0) {
      visited[b - 1] = 1;
      dis[b - 1] = dis[b] + 1;
      q.push(b - 1);
    }
    if (!visited[a[b]]) {
      visited[a[b]] = 1;
      dis[a[b]] = dis[b] + 1;
      q.push(a[b]);
    }
  }
}
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    memset(visited, 0, sizeof(visited));
    bfs();
    for (int i = 1; i <= n; i++) {
      if (i == 1)
        cout << dis[i];
      else
        cout << " " << dis[i];
    }
    cout << endl;
  }
  return 0;
}
