#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 10;
queue<int> bat;
vector<int> G[MAX_N];
bool check[MAX_N];
int dist[MAX_N];
void BFS() {
  int s = bat.size();
  for (int i = 0; i < s; i++) {
    for (auto i : G[bat.front()]) {
      if (!check[i]) {
        check[i] = true;
        dist[i] = dist[bat.front()] + 1;
        bat.push(i);
      }
    }
    bat.pop();
  }
  if (bat.empty()) return;
  BFS();
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    G[i].push_back(a - 1);
    if (i < n - 1) {
      G[i].push_back(i + 1);
      G[i + 1].push_back(i);
    }
  }
  check[0] = true;
  bat.push(0);
  BFS();
  for (int i = 0; i < n; i++) cout << dist[i] << ' ';
  return 0;
}
