#include <bits/stdc++.h>
using namespace std;
int n, ck[200005];
vector<int> v[200005];
struct info {
  int p, w;
  info(int a, int b) : p(a), w(b) {}
  bool operator<(const info &i) const { return w > i.w; }
};
int main() {
  scanf("%d", &n);
  for (int a, i = 1; i <= n; i++) {
    v[i].push_back(i + 1);
    v[i + 1].push_back(i);
    scanf("%d", &a);
    v[i].push_back(a);
  }
  priority_queue<info> pq;
  pq.push(info(1, 0));
  memset(ck, 1, sizeof(ck));
  ck[1] = 0;
  while (!pq.empty()) {
    info now = pq.top();
    pq.pop();
    for (int i = 0; i < v[now.p].size(); i++) {
      int next = v[now.p][i];
      if (ck[next] > now.w + 1) {
        ck[next] = now.w + 1;
        pq.push(info(next, ck[next]));
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", ck[i]);
}
