#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 2e5 + 5;
int n, a[N];
int ans[N];
void bfs() {
  queue<int> q;
  ans[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (!ans[a[cur]]) ans[a[cur]] = ans[cur] + 1, q.push(a[cur]);
    if (cur > 1 && !ans[cur - 1]) ans[cur - 1] = ans[cur] + 1, q.push(cur - 1);
    if (cur < n && !ans[cur + 1]) ans[cur + 1] = ans[cur] + 1, q.push(cur + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  bfs();
  for (int i = 1; i <= n; i++) cout << --ans[i] << " ";
  return 0;
}
