#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
vector<vector<int> > adjlist;
int n;
vector<int> bfs(int s) {
  vector<int> dist(n + 1, 1 << 30);
  dist[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(pair<int, int>(0, s));
  while (!pq.empty()) {
    pair<int, int> front = pq.top();
    pq.pop();
    int d = front.first;
    int u = front.second;
    if (d > dist[u]) continue;
    for (int j = 0; j < (int)adjlist[u].size(); j++) {
      int v = adjlist[u][j];
      if (dist[u] + 1 < dist[v]) {
        dist[v] = dist[u] + 1;
        pq.push(pair<int, int>(dist[v], v));
      }
    }
  }
  return dist;
}
int main() {
  cin >> n;
  adjlist.resize(n + 1);
  for (int i = 1; i < n; ++i) {
    adjlist[i].push_back(i + 1);
    adjlist[i].push_back(i - 1);
  }
  adjlist[n].push_back(n - 1);
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    adjlist[i].push_back(a);
  }
  vector<int> res = bfs(1);
  for (int i = 1; i <= n; ++i) cout << res[i] << " ";
  cout << endl;
}
