#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 100;
const int inf = 0x3f3f3f3f;
char s[100];
int have[100];
int n;
int d[N];
struct edge {
  int v, w;
};
vector<edge> G[N];
int op1() {
  if (have[1] || have[2] || have[3]) return 1;
  return 0;
}
void dij() {
  for (int i = 1; i <= n; i++) d[i] = i == 1 ? 0 : inf;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  Q.push(pair<int, int>(0, 1));
  while (!Q.empty()) {
    pair<int, int> t = Q.top();
    Q.pop();
    int dis = t.first;
    int u = t.second;
    if (dis != d[u]) continue;
    for (int i = 0; i < G[u].size(); i++) {
      edge e = G[u][i];
      int v = e.v;
      int w = e.w;
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        Q.push(pair<int, int>(d[v], v));
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    G[i].push_back((edge){i + 1, 1});
    G[i + 1].push_back((edge){i, 1});
  }
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    G[i].push_back((edge){t, 1});
  }
  dij();
  for (int i = 1; i <= n; i++) {
    printf("%d%c", d[i], i == n ? '\n' : ' ');
  }
  return 0;
}
