#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int n, vector<int> shortcuts) {
  auto distance = vector<int>(n, -1);
  distance[0] = 0;
  auto queue = std::queue<int>();
  queue.push(0);
  auto consider_edge = [&](int v, int w) {
    if (distance[w] != -1) return;
    distance[w] = distance[v] + 1;
    queue.push(w);
  };
  while (!queue.empty()) {
    auto v = queue.front();
    queue.pop();
    if (v != 0) consider_edge(v, v - 1);
    if (v != n - 1) consider_edge(v, v + 1);
    consider_edge(v, shortcuts[v]);
  }
  return distance;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  auto shortcuts = vector<int>(n);
  for (auto i = 0; i < n; i++) {
    cin >> shortcuts[i];
    shortcuts[i]--;
  }
  auto solution = solve(n, shortcuts);
  for (auto x : solution) cout << x << " ";
  cout << endl;
}
