#include <bits/stdc++.h>
using namespace std;
long long const mod = 1000000007;
long long const md = 998244353l;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ifstream in("txt.in");
ofstream out("txt.out");
int f[200005], cost[200005];
long long n;
void dfs(long long x, long long t) {
  if (cost[x] <= t) return;
  cost[x] = t;
  dfs(f[x], t + 1);
  if (x - 1 > 0) dfs(x - 1, t + 1);
  if (x + 1 <= n) dfs(x + 1, t + 1);
}
int main() {
  cout << fixed << setprecision(12);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> f[i];
  }
  for (int i = 1; i <= n; ++i) {
    cost[i] = 2e9;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    cout << cost[i] << " ";
  }
  return 0;
}
