#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int ss[maxn];
int n, dd[maxn];
bool vis[maxn];
int main() {
  scanf("%d", &n);
  memset(vis, 0, sizeof(vis));
  memset(ss, 0, sizeof(ss));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &dd[i]);
  }
  queue<int> Q;
  Q.push(1);
  vis[1] = 1;
  while (!Q.empty()) {
    int tmp = Q.front();
    Q.pop();
    if (tmp > 2 && !vis[tmp - 1]) {
      ss[tmp - 1] = ss[tmp] + 1;
      vis[tmp - 1] = 1;
      Q.push(tmp - 1);
    }
    if (tmp < n && !vis[tmp + 1]) {
      ss[tmp + 1] = ss[tmp] + 1;
      vis[tmp + 1] = 1;
      Q.push(tmp + 1);
    }
    if (!vis[dd[tmp]] && dd[tmp] != tmp) {
      ss[dd[tmp]] = ss[tmp] + 1;
      vis[dd[tmp]] = 1;
      Q.push(dd[tmp]);
    }
  }
  printf("%d", ss[1]);
  for (int i = 2; i <= n; i++) {
    printf(" %d", ss[i]);
  }
  printf("\n");
  return 0;
}
