#include <bits/stdc++.h>
using namespace std;
vector<int> v[1000000];
queue<int> q;
int d[1000000];
int n;
int x;
int fr;
int ob[1000000];
void bfs() {
  q.push(1);
  while (!q.empty()) {
    fr = q.front();
    q.pop();
    for (int i = 0; i < v[fr].size(); i++)
      if (d[v[fr][i]] == -1) {
        d[v[fr][i]] = d[fr] + 1;
        q.push(v[fr][i]);
      }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x != i) v[i].push_back(x);
    if (i != 1) v[i].push_back(i - 1);
    if (i != n) v[i].push_back(i + 1);
  }
  for (int i = 1; i <= n; i++) d[i] = -1;
  d[1] = 0;
  bfs();
  for (int i = 1; i <= n; i++) printf("%d ", d[i]);
  return 0;
}
