#include <bits/stdc++.h>
using namespace std;
int n;
int a[201000];
int f[201000];
queue<int> q;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(f, 0x3f, sizeof f);
  f[1] = 0;
  q.push(1);
  while (q.size()) {
    int x = q.front();
    q.pop();
    if (x - 1 > 0)
      if (f[x - 1] == 0x3f3f3f3f) f[x - 1] = f[x] + 1, q.push(x - 1);
    if (x + 1 <= n)
      if (f[x + 1] == 0x3f3f3f3f) f[x + 1] = f[x] + 1, q.push(x + 1);
    if (f[a[x]] == 0x3f3f3f3f) f[a[x]] = f[x] + 1, q.push(a[x]);
  }
  for (int i = 1; i <= n; i++) printf("%d ", f[i]);
  printf("\n");
}
