#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], n, f[maxn];
void dp(int x) {
  if (x > n) return;
  if (f[a[x]] > f[x] + 1) {
    f[a[x]] = f[x] + 1;
    dp(a[x]);
  }
  if (f[x - 1] > f[x] + 1) {
    f[x - 1] = f[x] + 1;
    dp(x - 1);
  }
  if (f[x + 1] > f[x] + 1) {
    f[x + 1] = f[x] + 1;
    dp(x + 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  memset(f, 63, sizeof(f));
  f[1] = f[0] = 0;
  dp(1);
  for (int i = 1; i <= n; ++i) {
    cout << f[i] << ' ';
  }
  cout << endl;
  ;
  return 0;
}
