#include <bits/stdc++.h>
using namespace std;
vector<int> g[200005];
int used[200005];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int a;
    scanf("%d", &a);
    g[i].push_back(i - 1);
    g[i].push_back(i + 1);
    g[i].push_back(a);
  }
  fill(used, used + 200005, -1);
  queue<int> q;
  q.push(1);
  used[1] = 0;
  while (q.size()) {
    int a = q.front();
    q.pop();
    for (int i = 0; i < g[a].size(); ++i) {
      if (used[g[a][i]] == -1) {
        q.push(g[a][i]);
        used[g[a][i]] = used[a] + 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d ", used[i]);
  }
}
