#include <bits/stdc++.h>
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
const int N = 200005;
const int M = 20;
const long long INF = 1e18 + 1;
int mod = 1000000007;
int n, m, k;
int a[N] = {0}, d[N] = {0}, used[N] = {0};
vector<int> v[N];
void bfs(int k) {
  fill(d, d + N, mod);
  d[k] = 0;
  used[k] = 1;
  queue<int> q;
  q.push(k);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < v[u].size(); i++)
      if (used[v[u][i]] == 0) {
        used[v[u][i]] = 1;
        d[v[u][i]] = d[u] + 1;
        q.push(v[u][i]);
      }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (i + 1 < n) {
      v[i].push_back(i + 1);
      v[i + 1].push_back(i);
    }
    v[i].push_back(a[i] - 1);
  }
  bfs(0);
  for (int i = 0; i < n; i++) cout << d[i] << ' ';
  return 0;
}
