#include <bits/stdc++.h>
using namespace std;
using std::make_pair;
const int maxn = 200000 + 100;
const int inf = 0x3f3f3f3f;
int dist[maxn];
int inQue[maxn];
int a[maxn];
queue<int> q;
vector<pair<int, int> > g[maxn + 10];
int n, m;
void spfa() {
  memset(dist, inf, sizeof(dist));
  memset(inQue, 0, sizeof(inQue));
  dist[1] = 0;
  while (!q.empty()) q.pop();
  q.push(1);
  inQue[1] = 1;
  while (!q.empty()) {
    int u = q.front();
    int temp = 0;
    q.pop();
    for (int i = 0; i < g[u].size(); i++) {
      temp = min(g[u][i].second, abs(g[u][i].first - u));
      if (dist[u] + temp < dist[g[u][i].first]) {
        dist[g[u][i].first] = dist[u] + temp;
        if (!inQue[g[u][i].first]) {
          inQue[g[u][i].first] = 1;
          q.push(g[u][i].first);
        }
      }
    }
    inQue[u] = 0;
  }
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) g[i].clear();
    for (int i = 2; i <= n; i++) {
      g[i].push_back(make_pair(i - 1, 1));
      g[i - 1].push_back(make_pair(i, 1));
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == i)
        g[i].push_back(make_pair(a[i], 0));
      else
        g[i].push_back(make_pair(a[i], 1));
    }
    spfa();
    for (int i = 1; i <= n; i++) printf("%d ", dist[i]);
    printf("\n");
  }
  return 0;
}
