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