#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000001];
int q[1000001], qh = 0, qt = 1;
int d[1000001];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    --a[i];
    d[i] = n + 100;
  }
  d[0] = 0;
  q[0] = 0;
  while (qh != qt) {
    int cur = q[qh];
    qh++;
    if (d[a[cur]] > n + 1) {
      d[a[cur]] = d[cur] + 1;
      q[qt] = a[cur];
      qt++;
    }
    if (cur + 1 < n && d[cur + 1] > n + 1) {
      d[cur + 1] = d[cur] + 1;
      q[qt] = cur + 1;
      qt++;
    }
    if (cur - 1 >= 0 && d[cur - 1] > n + 1) {
      d[cur - 1] = d[cur] + 1;
      q[qt] = cur - 1;
      qt++;
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", d[i]);
  }
}
