#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int a[N];
int vis[N];
int n;
void bfs() {
  queue<int> que;
  memset(vis, -1, sizeof(vis));
  vis[1] = 0;
  vis[0] = 0;
  que.push(1);
  while (!que.empty()) {
    int cur = que.front();
    que.pop();
    vector<int> next = {a[cur], cur - 1, cur + 1};
    for (auto x : next) {
      if (vis[x] != -1 || x > n) continue;
      vis[x] = vis[cur] + 1;
      que.push(x);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  bfs();
  for (int i = 1; i <= n; ++i) {
    printf("%d%c", vis[i], " \n"[i == n]);
  }
  return 0;
}
