#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const int logn = 18;
const int inf = (int)1e9 + 5;
const long long mod = (long long)1e9 + 7;
const long long base = 2204234849;
const long long l_inf = (long long)4e18;
const long double pi = acos(-1.0);
const long double eps = 1e-12;
int n;
vector<int> g[maxn];
int dist[maxn];
void solve() {
  set<pair<int, int> > s;
  for (int i = 1; i < n; i++) dist[i] = inf;
  s.insert(make_pair(0, 0));
  while (!s.empty()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (int u : g[v]) {
      if (dist[v] + 1 < dist[u]) {
        s.erase(make_pair(dist[u], u));
        dist[u] = dist[v] + 1;
        s.insert(make_pair(dist[u], u));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(20);
  cout << fixed;
  srand(566);
  cin >> n;
  for (int v = 0; v < n; v++) {
    int u;
    cin >> u;
    g[v].push_back(--u);
    if (v > 0) g[v].push_back(v - 1);
    if (v + 1 < n) g[v].push_back(v + 1);
  }
  solve();
  for (int i = 0; i < n; i++) cout << dist[i] << ' ';
  return 0;
}
