#include <bits/stdc++.h>
using namespace std;
int n;
int t[1000010], d[1000010], fr[1000010], lastl[1000010], lastr[1000010];
vector<int> g[1000010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int i = 1; i <= n; i++) g[i].push_back(t[i]), d[i] = 2e9;
  for (int i = 1; i < n; i++) g[i].push_back(i + 1), g[i + 1].push_back(i);
  queue<int> que;
  que.push(1);
  d[1] = 0;
  fr[1] = 1;
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = 0; i < (int)g[x].size(); i++)
      if (fr[g[x][i]] == 0) {
        d[g[x][i]] = d[x] + 1;
        fr[g[x][i]] = 1;
        que.push(g[x][i]);
      }
  }
  for (int i = 1; i <= n; i++) printf("%d ", d[i]);
  return 0;
}
