#include <bits/stdc++.h>
using namespace std;
const long long inf = 1ll << 50;
int n;
long long dist[200000 + 10];
vector<long long> graph[200000 + 10];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int v;
    cin >> v;
    graph[i].push_back(v);
  }
  for (int i = 1; i < n; i++) {
    graph[i].push_back(i + 1);
    graph[i + 1].push_back(i);
  }
  for (int i = 1; i < n + 1; i++) dist[i] = inf;
  queue<int> q;
  q.push(1);
  dist[1] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto &v : graph[u]) {
      if (dist[v] == inf) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
  for (int i = 1; i < n + 1; i++) cout << dist[i] << " ";
}
