#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200200, INF = 0x3f3f3f3f;
int n, cur, dist[MAXN], a[MAXN];
vector<int> neigh(int x) {
  vector<int> ans;
  if (x > 1) ans.push_back(x - 1);
  if (x < n) ans.push_back(x + 1);
  ans.push_back(a[x]);
  return ans;
}
void dijkstra() {
  memset(dist, INF, sizeof dist);
  dist[1] = 0;
  priority_queue<pair<int, int> > q;
  q.push(pair<int, int>(-dist[1], 1));
  while (!q.empty()) {
    cur = q.top().second, q.pop();
    for (const int& u : neigh(cur))
      if (dist[u] > dist[cur] + 1)
        dist[u] = dist[cur] + 1, q.push(pair<int, int>(-dist[u], u));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  dijkstra();
  for (int i = 1; i <= n; ++i) printf("%d ", dist[i]);
}
