#include <bits/stdc++.h>
using namespace std;
long long int vis[1000010], path[1000010];
vector<long long int> v[1000010];
void BFS() {
  memset(vis, 0, sizeof(vis));
  queue<long long int> Q;
  Q.push(1);
  path[1] = 0;
  vis[1] = 1;
  while (!Q.empty()) {
    long long int node = Q.front();
    Q.pop();
    for (int i = 0; i < v[node].size(); i++) {
      if (vis[v[node][i]] == 0) {
        vis[v[node][i]] = 1;
        path[v[node][i]] = path[node] + 1;
        Q.push(v[node][i]);
      }
    }
  }
}
int main() {
  long long int x, n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    v[i].push_back(x);
    v[i].push_back(i + 1);
    v[i].push_back(i - 1);
  }
  BFS();
  for (i = 1; i <= n; i++) {
    cout << path[i] << " ";
  }
  cout << endl;
  return 0;
}
