#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> g[n + 1];
  for (int i = 1; i < n; ++i) {
    g[i].push_back(i + 1);
  }
  for (int i = n; i > 1; i--) {
    g[i].push_back(i - 1);
  }
  for (int u = 1; u <= n; ++u) {
    int v;
    cin >> v;
    if (u != v) g[u].push_back(v);
  }
  vector<int> distance(n + 1, 0);
  vector<bool> visited(n + 1, false);
  queue<int> q;
  q.push(1);
  visited[1] = true;
  distance[1] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (!visited[v]) {
        visited[v] = true;
        distance[v] = distance[u] + 1;
        q.push(v);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << distance[i] << " ";
  }
  return 0;
}
