#include <bits/stdc++.h>
using namespace std;
int mark[200001], h[200001];
vector<int> v[200001];
queue<int> q;
int main() {
  int n, a;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    v[i].push_back(a);
  }
  for (int i = 1; i < n; i++) {
    v[i].push_back(i + 1);
    v[i + 1].push_back(i);
  }
  q.push(1);
  mark[1] = 1;
  while (q.size()) {
    int now = q.front();
    q.pop();
    for (int i = 0; i < v[now].size(); i++) {
      int child = v[now][i];
      if (!mark[child]) {
        mark[child] = 1;
        q.push(child);
        h[child] = h[now] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << h[i] << ' ';
}
