#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn], d[maxn];
int n;
void bfs() {
  queue<int> q;
  d[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (!d[a[v]]) {
      d[a[v]] = d[v] + 1;
      q.push(a[v]);
    }
    if (v > 1 && !d[v - 1]) {
      d[v - 1] = d[v] + 1;
      q.push(v - 1);
    }
    if (v < n && !d[v + 1]) {
      d[v + 1] = d[v] + 1;
      q.push(v + 1);
    }
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    cout << d[i] - 1 << " ";
  }
  return 0;
}
