#include <bits/stdc++.h>
using namespace std;
int jj[200001];
int lf[200001];
void bfs() {
  queue<int> q;
  q.push(1);
  lf[1] = 0;
  int now;
  while (!q.empty()) {
    now = q.front();
    q.pop();
    if (lf[now + 1] > lf[now] + 1) {
      lf[now + 1] = lf[now] + 1;
      q.push(now + 1);
    }
    if (lf[now - 1] > lf[now] + 1) {
      lf[now - 1] = lf[now] + 1;
      q.push(now - 1);
    }
    if (lf[jj[now]] > lf[now] + 1) {
      lf[jj[now]] = lf[now] + 1;
      q.push(jj[now]);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &jj[i]);
    lf[i] = 0x3f3f3f3f;
  }
  bfs();
  for (int i = 1; i <= n - 1; ++i) printf("%d ", lf[i]);
  printf("%d\n", lf[n]);
  return 0;
}
