#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int d[maxn], sh[maxn], vis[maxn], n;
void solve() {
  memset(d, 0x3f3f3f3f, sizeof(d));
  d[1] = 0;
  queue<int> q;
  q.push(1);
  vis[1] = vis[0] = 1;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if (d[t + 1] > d[t] + 1) {
      d[t + 1] = d[t] + 1;
      if (!vis[t + 1]) q.push(t + 1);
      vis[t + 1] = 1;
    }
    if (d[sh[t]] > d[t] + 1) {
      d[sh[t]] = d[t] + 1;
      if (!vis[sh[t]]) q.push(sh[t]);
      vis[sh[t]] = 1;
    }
    if (d[t - 1] > d[t] + 1) {
      d[t - 1] = d[t] + 1;
      if (!vis[t - 1]) q.push(t - 1);
      vis[t - 1] = 1;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &sh[i]);
  solve();
  for (int i = 1; i <= n; ++i) printf("%d%c", d[i], i == n ? '\n' : ' ');
  return 0;
}
