#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
const long long mod = 1e9 + 7;
long long power(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
long long add(long long a, long long b) { return (a % mod + b % mod) % mod; }
long long mul(long long a, long long b) { return (a % mod * b % mod) % mod; }
long long n, m;
inline bool in(long long x, long long y) {
  return ((x >= 1 and x <= n) and (y >= 1 and y <= m));
}
queue<long long> qt;
vector<long long> adj[N];
long long dis[N];
long long vis[N];
long long idx[] = {0, -1, 0, 1};
long long idy[] = {1, 0, -1, 0};
void bfs(long long x) {
  qt.push(x);
  while (!qt.empty()) {
    long long x = qt.front();
    qt.pop();
    vis[x] = 1;
    for (auto i : adj[x]) {
      if (!vis[i] and dis[i] > dis[x] + 1) {
        dis[i] = dis[x] + 1;
        qt.push(i);
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    adj[i].push_back(x);
    if (i != n) {
      adj[i].push_back(i + 1);
      adj[i + 1].push_back(i);
    }
  }
  fill(dis, dis + n + 1, INT_MAX);
  dis[1] = 0;
  bfs(1);
  for (long long i = 1; i <= n; i++) cout << dis[i] << " ";
}
