#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& fout, const vector<T>& vec) {
  for (const auto& el : vec) {
    fout << el << ' ';
  }
  return fout;
}
template <class T>
istream& operator>>(istream& fin, vector<T>& vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cin >> vec[i];
  }
  return fin;
}
int Solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  vector<int> dp(n, 1e9);
  dp[0] = 0;
  queue<int> q;
  q.push(0);
  vector<bool> used(n);
  used[0] = 1;
  while (q.size()) {
    int cur = q.front();
    int len = dp[cur];
    q.pop();
    if (used[a[cur] - 1] == 0) {
      q.push(a[cur] - 1);
      dp[a[cur] - 1] = len + 1;
      used[a[cur] - 1] = true;
    }
    if (cur > 0 && used[cur - 1] == 0) {
      q.push(cur - 1);
      dp[cur - 1] = len + 1;
      used[cur - 1] = true;
    }
    if (cur + 1 < n && used[cur + 1] == 0) {
      q.push(cur + 1);
      dp[cur + 1] = len + 1;
      used[cur + 1] = true;
    }
  }
  cout << dp << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
