#include <bits/stdc++.h>
using namespace std;
class Graph {
  long long int v;
  list<pair<long long int, long long int>> *adj;

 public:
  Graph(long long int v) : v(v) {
    adj = new list<pair<long long int, long long int>>[v];
  }
  void addEdge(long long int u, long long int v, long long int w,
               bool bidir = true) {
    adj[u].push_back(make_pair(v, w));
    if (bidir) adj[v].push_back(make_pair(u, w));
  }
  void dijkstra() {
    vector<long long int> distance(v, LONG_MAX);
    priority_queue<pair<long long int, long long int>,
                   vector<pair<long long int, long long int>>,
                   greater<pair<long long int, long long int>>>
        pq;
    pq.push(make_pair(0, 0));
    distance[0] = 0;
    while (!pq.empty()) {
      auto ele = pq.top();
      pq.pop();
      for (auto itr = adj[ele.second].begin(); itr != adj[ele.second].end();
           itr++) {
        long long int v = itr->first;
        long long int weight = itr->second;
        if (distance[ele.second] != LONG_MAX &&
            distance[ele.second] + weight < distance[v]) {
          distance[v] = distance[ele.second] + weight;
          pq.push(make_pair(distance[v], v));
        }
      }
    }
    for (auto ele : distance) cout << ele << " ";
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  Graph g(n);
  for (long long int i = 0; i < n - 1; i++) g.addEdge(i, i + 1, 1);
  for (long long int i = 0; i < n; i++)
    if (i != v[i] - 1) g.addEdge(i, v[i] - 1, 1, false);
  g.dijkstra();
  return 0;
}
