#include <bits/stdc++.h>
using namespace std;
const long long M = 3e5 + 7, K = (1 << 10) + 7, mod = 1000000007;
std::vector<long long> g[M];
long long V[M], dp[M];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  {
    long long n;
    cin >> n;
    for (long long i = 1; i <= n; i++) {
      long long x;
      cin >> x;
      if (x != i) {
        g[i].push_back(x);
      }
      if (i != n) {
        g[i].push_back(i + 1);
      }
      if (i != 1) {
        g[i].push_back(i - 1);
      }
    }
    V[1] = 1, dp[1] = 0;
    queue<long long> q;
    q.push(1);
    while (!q.empty()) {
      long long node = q.front();
      q.pop();
      for (auto u : g[node]) {
        if (V[u]) continue;
        V[u] = 1;
        dp[u] = dp[node] + 1;
        q.push(u);
      }
    }
    for (long long i = 1; i <= n; i++) cout << dp[i] << " ";
    cout << "\n";
  }
  return 0;
}
