#include <bits/stdc++.h>
using namespace std;
int f[1000001];
struct xzy {
  int x, y, z;
} b[2000001];
int next_[2000001], start_[500001];
int main() {
  int n, m;
  memset(f, 14, sizeof(f));
  cin >> n;
  for (int i = 1; i < n; i++) {
    b[i].x = i;
    b[i].y = i + 1;
    b[i].z = 1;
    b[i + n - 1].x = b[i].y;
    b[i + n - 1].y = b[i].x;
    b[i + n - 1].z = b[i].z;
    next_[i] = start_[b[i].x];
    start_[b[i].x] = i;
  }
  for (int i = n; i <= n * 2 - 2; i++) {
    next_[i] = start_[b[i].x];
    start_[b[i].x] = i;
  }
  for (int i = n * 2 - 1; i <= n * 3 - 2; i++) {
    int x;
    scanf("%d", &x);
    b[i].x = i - (n * 2 - 2);
    b[i].y = x;
    b[i].z = 1;
    next_[i] = start_[b[i].x];
    start_[b[i].x] = i;
  }
  queue<int> q;
  q.push(1);
  f[1] = 0;
  while (!q.empty()) {
    int x = q.front(), j = start_[x];
    q.pop();
    while (j != 0) {
      int a1 = b[j].x, a2 = b[j].y, a3 = b[j].z;
      if (f[a2] > f[a1] + a3) {
        f[a2] = f[a1] + a3;
        q.push(a2);
      }
      j = next_[j];
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", f[i]);
  }
  return 0;
}
