#include <bits/stdc++.h>
using namespace std;
long long int dist[200001];
void dijkstra(int v[3][200001], int n, int start) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      nodes;
  pair<int, int> ac;
  vector<int> pesos(n + 1, 0x3f3f3f3f);
  vector<bool> usados(n + 1, false);
  pesos[start] = 0;
  nodes.push(make_pair(0, start));
  while (!nodes.empty()) {
    ac = nodes.top();
    nodes.pop();
    int atual = ac.second;
    while (!nodes.empty() and usados[atual]) {
      ac = nodes.top();
      atual = ac.second;
      nodes.pop();
    }
    if (usados[atual]) break;
    if (pesos[v[0][atual]] > pesos[atual] + 1) {
      pesos[v[0][atual]] = pesos[atual] + 1;
      nodes.push(make_pair(pesos[atual] + 1, v[0][atual]));
    }
    if (pesos[v[1][atual]] > pesos[atual] + 1) {
      pesos[v[1][atual]] = pesos[atual] + 1;
      nodes.push(make_pair(pesos[atual] + 1, v[1][atual]));
    }
    if (pesos[v[2][atual]] > pesos[atual] + 1) {
      pesos[v[2][atual]] = pesos[atual] + 1;
      nodes.push(make_pair(pesos[atual] + 1, v[2][atual]));
    }
    usados[atual] = true;
  }
  for (int i = 1; i <= n; i++) dist[i] = pesos[i];
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int v[3][200001];
  for (int i = 1; i <= n; i++) {
    cin >> v[0][i];
    v[1][i] = i + 1;
    v[2][i] = i - 1;
  }
  v[1][n] = n;
  v[2][1] = 1;
  dijkstra(v, n, 1);
  for (int i = 1; i <= n; i++) cout << dist[i] << ' ';
  cout << endl;
  return 0;
}
