#include <bits/stdc++.h>
using namespace std;
std::vector<int> adj[200006];
int a[200006], d[200006];
bool vis[200006];
queue<int> q;
void bfs(int v, int n) {
  d[v] = 0;
  q.push(v);
  vis[v] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      if (adj[u][i] < n && adj[u][i] >= 0 && !vis[adj[u][i]]) {
        d[adj[u][i]] = d[u] + 1;
        q.push(adj[u][i]);
        vis[adj[u][i]] = 1;
      }
    }
  }
}
int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    adj[i].push_back(a[i] - 1);
    adj[i].push_back(i + 1);
    adj[i].push_back(i - 1);
  }
  bfs(0, n);
  for (i = 0; i < n; i++) cout << d[i] << " ";
  cout << endl;
}
